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 |
帮忙看一下,我的代码是哪里做了,怎么总是wrong啊!!#include <iostream> using namespace std; int r[10000];//行 int l[10000];//列 int a[10000]; int b[100][100]; int c[100][100]; int m,n; void input() { cin>>m>>n; int num=0; int k=0; for(int i=0;i<m;i++) { for(int j=0;j<n;j++) { cin>>k; r[num]=i; l[num]=j; a[num]=k; b[i][j]=k; c[i][j]=0; num++; } } } void selectsort() { int k; int t; for(int i=0;i<m*n-1;i++) { k=i; for(int j=i+1;j<m*n;j++) { if(a[k]>a[j]) k=j; } t=a[i]; a[i]=a[k]; a[k]=t; t=r[i]; r[i]=r[k]; r[k]=t; t=l[i]; l[i]=l[k]; l[k]=t; } } int run() { selectsort(); int max=0; for(int i=0;i<m*m;i++) { if(r[i]!=0&&b[r[i]][l[i]]>b[r[i]-1][l[i]]) { c[r[i]][l[i]]=c[r[i]-1][l[i]] > c[r[i]][l[i]]?c[r[i]-1][l[i]]:c[r[i]][l[i]]; } if(r[i]!=n-1&&b[r[i]][l[i]]>b[r[i]+1][l[i]]) { c[r[i]][l[i]]=c[r[i]+1][l[i]] > c[r[i]][l[i]]?c[r[i]+1][l[i]]:c[r[i]][l[i]]; } if(l[i]!=0&&b[r[i]][l[i]]>b[r[i]][l[i]-1]) { c[r[i]][l[i]]=c[r[i]][l[i]-1] > c[r[i]][l[i]]?c[r[i]][l[i]-1]:c[r[i]][l[i]]; } if(l[i]!=n-1&&b[r[i]][l[i]]>b[r[i]][l[i]+1]) { c[r[i]][l[i]]=c[r[i]][l[i]+1] > c[r[i]][l[i]]?c[r[i]][l[i]+1]:c[r[i]][l[i]]; } c[r[i]][l[i]]++; max=c[r[i]][l[i]]>max?c[r[i]][l[i]]:max; } return max; } void output() { cout<<run()<<endl; } int main() { input(); output(); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator