Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

求错

Posted by matrixqc at 2012-05-29 14:53:12 on Problem 1088
#include <stdio.h>
#include <iostream>
using namespace std;
long a[101][101]={-30000},f[101][101]={0};
long ans;
long max(long a,long b){
if (a>b) return a; return b;
}
long DFS(long x,long y){
     long t=0;
     if (f[x][y]!=0) return f[x][y];
     if (a[x][y]<a[x-1][y]) t=max(DFS(x-1,y),t);
     if (a[x][y]<a[x+1][y]) t=max(DFS(x+1,y),t);
     if (a[x][y]<a[x][y+1]) t=max(DFS(x,y+1),t);
     if (a[x][y]<a[x][y-1]) t=max(DFS(x,y-1),t);
     f[x][y]=t+1;      
     return f[x][y];
}
int main(){
    long ans=0;
    long m,n;
    scanf("%d%d",&m,&n);
    for (long i=1; i<=m; i++)
        for (long j=1; j<=n; j++)
        scanf("%d",&a[i][j]);
    for (long i=1; i<=m; i++)
        for (long j=1; j<=n; j++)
        ans=max(DFS(i,j),ans);   
    printf("%d",ans); 
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator