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

1088ac代码 免费看

Posted by gaoxiaomeng at 2008-08-15 16:41:44
#include <iostream>
#include  <math.h>
using namespace std;
int  B[4][2]={{0,-1},{-1,0},{0,1},{1,0}};
int  flag[101][101]={0};
int  A[103][103]={0};
int  f(int i,int j)
{   int  x,y;
    if(flag[i][j]!=0)   return flag[i][j];
      else  {
          for(int  a=0;a<4;a++)
          {  x=i+B[a][0];
              y=j+B[a][1];
            if(A[i][j]>A[x][y])   flag[i][j]=max(flag[i][j],f(x,y)+1);
          }
          if(flag[i][j]==0)  flag[i][j]=1;
          return   flag[i][j];
      }
}

int main()
{
 int R,C;
  scanf("%d%d",&R,&C);
  for(int i=0;i<=C+1;i++)
    {A[0][i]=10001;A[R+1][i]=10001;}
    for(int  i=0;i<=R+1;i++)
    {A[i][0]=10001;A[i][C+1]=10001;}
 for(int  i=1;i<=R;i++)
    for(int j=1;j<=C;j++)
      scanf("%d",&A[i][j]);
                int   maxn=1;
        for(int  i=1;i<=R;i++)
           for(int  j=1;j<=C;j++)
           {if(f(i,j)>maxn)  maxn=f(i,j);}
           printf("%d\n",maxn);
           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