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 |
改了一下 pass 不过还可以在改进一些#include <iostream> using namespace std; const int x[4]={1,-1,0,0},y[4]={0,0,1,-1}; void main() { int rep,i,j,p,r,c,a[100][100],l[100][100]; unsigned min=-1,max=0; cin>>r>>c; for(i=0;i<r;i++) for(j=0;j<c;j++) { cin>>a[i][j]; min=min>a[i][j]?a[i][j]:min; max=max<a[i][j]?a[i][j]:max; } memset (l,0,100*100*sizeof(int)); for(;;) { for(i=0;i<r;i++) for(j=0;j<c;j++) { if(min==a[i][j]) for(p=0;p<4;p++) if(i+x[p]>=0&&i+x[p]<r&&j+y[p]>=0&&j+y[p]<c) if((a[i][j]-a[i+x[p]][j+y[p]]>0)&&(l[i][j]<l[i+x[p]][j+y[p]]+1)) { l[i][j]=l[i+x[p]][j+y[p]]+1;rep=1; } } min++; if(min==max+1) break; } rep=0; for(i=0;i<r;i++) for(j=0;j<c;j++) if(l[i][j]>rep) rep=l[i][j]; cout<<rep+1<<endl; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator