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 |
帮忙看看啊,老是超时啊。。。。#include <stdio.h> #include <stdlib.h> int max = 0, R, C; void look(int N[][101],int i, int j, int now); int main() { int now=1; int i,j; int N[101][101] = {0}; scanf("%d %d",&R,&C); for(i=0; i<R; i++) for(j=0; j<R; j++) scanf("%d", &N[i][j]); R--,C--; for(i=0; i<=R; i++) for(j=0; j<=C; j++) look(N,i,j,now); printf("%d\n", max); return 0; } void look(int N[][101], int i, int j, int now) { int flag=1; if(i>0 && N[i-1][j]<N[i][j]) look(N,i-1,j,now+1),flag=0; if(j>0 && N[i][j-1] < N[i][j]) look(N,i,j-1,now+1),flag=0; if(i<R && N[i+1][j]<N[i][j]) look(N,i+1,j,now+1),flag=0; if(j<C && N[i][j+1]<N[i][j]) look(N,i,j+1,now+1),flag=0; if(flag&&max < now) max = now; return; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator