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 |
抱着必TEL 之心···居然随便就能过···晕··第一次搜索 蒙着写 居然过····无限汗····#include <iostream> using namespace std; int a[1000][1000]={0}; int b[1000][1000]={0}; int c[1000][1000]={0}; int it,jt; int p,q; void serch(int i,int j) { b[i][j]=1; if(a[i][j]<a[i][j+1]) { if(b[i][j+1]!=1) { // b[i][j+1]=1; serch(i,j+1); } if(c[i][j+1]+1>c[i][j]) { c[i][j]=c[i][j+1]+1; } } if(a[i][j]<a[i][j-1]) { if(b[i][j-1]!=1) { // b[i][j-1]=1; serch(i,j-1); } if(c[i][j-1]+1>c[i][j]) { c[i][j]=c[i][j-1]+1; } } if(a[i][j]<a[i+1][j]) { if(b[i+1][j]!=1) { // b[i+1][j]=1; serch(i+1,j); } if(c[i+1][j]+1>c[i][j]) { c[i][j]=c[i+1][j]+1; } } if(a[i][j]<a[i-1][j]) { if(b[i-1][j]!=1) { // b[i-1][j]=1; serch(i-1,j); } if(c[i-1][j]+1>c[i][j]) { c[i][j]=c[i-1][j]+1; } } } int main() { int m,n; int min=10000; int mark1,mark2; cin>>m>>n; for(it=1;it<=m;it++) { for(jt=1;jt<=n;jt++) { cin>>a[it][jt]; if(a[it][jt]<min) { mark1=it; mark2=jt; } } } for(it=1;it<=m;it++) { for(jt=1;jt<=n;jt++) { b[it][jt]=0; } } for(q=1;q<=m;q++) { for(p=1;p<=n;p++) { if(b[q][p]!=1) { serch(q,p); } } } int max=0; for(it=1;it<=m;it++) { for(jt=1;jt<=n;jt++) { if(c[it][jt]>max) { max=c[it][jt]; } // cout<<c[it][jt]; } // cout<<endl; } cout<<max+1<<endl; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator