| ||||||||||
| 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 | |||||||||
Re:1088滑雪的测试数据谁有,例子那个我对,提交就错In Reply To:1088滑雪的测试数据谁有,例子那个我对,提交就错 Posted by:iphilip at 2009-10-21 19:34:31 > #include <stdio.h>
>
> #define MAX 102
> #define INFINIT 999999
>
> int N,M;
> int m[MAX][MAX];
> int h[MAX][MAX]={0};
>
> int search(int ,int );
>
> int main() {
> int i,j;
> int max = 0;
> scanf( "%d%d",&M,&N );
> for( i=1;i<=M;i++ ) {
> for( j=1;j<=N;j++ ) {
> scanf( "%d",&m[i][j] );
> }
> }
> for( i=0;i<=N+1;i++ ) {
> m[0][i] = INFINIT;
> m[M+1][i] = INFINIT;
> }
>
> for( j=0;j<=M+1;j++ ) {
> m[j][0] = INFINIT;
> m[j][N+1] = INFINIT;
> }
>
> for( i=1;i<=N;i++ ) {
> for( j=1;j<=M;j++ ) {
> if( max < search(i,j) ) max = search(i,j);
> // printf( "%d-",search(i,j) );
> }
> //printf( "\n" );
> }
>
> printf( "%d\n",max );
>
> return 0;
> }
>
> int search( int i,int j) {
> int max =1;
> int cur = 0;
>
> if( h[i][j] ) return h[i][j];
>
> if( m[i][j] <m[i+1][j] && m[i][j] <m[i-1][j]
> && m[i][j] <m[i][j+1] && m[i][j]<m[i][j-1] ) {
> h[i][j] = 1;
> return 1;
> }
>
> if( m[i][j] > m[i+1][j] ) {
> cur = search( i+1,j );
> if( max < cur+1 ) max = cur+1;
> }
>
> if( m[i][j] > m[i-1][j] ) {
> cur = search( i-1,j );
> if( max < cur+1 ) max = cur+1;
> }
>
> if( m[i][j] > m[i][j+1] ) {
> cur = search( i,j+1 );
> if( max < cur+1 ) max = cur+1;
> }
>
> if( m[i][j] > m[i][j-1] ) {
> cur = search( i,j-1 );
> if( max < cur+1 ) max = cur+1;
> }
>
> h[i][j] = max;
> return max;
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator