Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
wa厚颜无耻的请各位大神来帮看眼*=*讨论的数据几乎都测了可还是wa啊... 在此拜谢过各位 #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> using namespace std; int data[1000][1000]; int c[1000][1000]; int a[4]={1,-1,0,0}; int b[4]={0,0,1,-1}; int n,m; int getAns(int x,int y) { for(int i=0;i<4;i++) { if(x+a[i]>0&&x+a[i]<=n&&y+b[i]>0&&y+b[i]<=m) { if(data[x][y]>data[x+a[i]][y+b[i]]) { if(c[x+a[i]][y+b[i]]==1) { c[x+a[i]][y+b[i]]=getAns(x+a[i],y+b[i]); } // c[x+a[i]][y+b[i]]=max(c[x+a[i]][y+b[i]],getAns(x+a[i],y+b[i])); c[x][y]=max(c[x][y],c[x+a[i]][y+b[i]]+1); } } } return c[x][y]; } int main() { // freopen("in.txt","r",stdin); cin>>n>>m; int i,j; for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { cin>>data[i][j]; c[i][j]=1; } } int ans=0; for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { ans=max(ans,getAns(i,j)); } } // for(i=1;i<=n;i++) // { // for(j=1;j<=m;j++) // { // cout<<c[i][j]<<" "; // } // cout<<endl; // } cout<<ans; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator