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 1004101213 at 2011-07-27 22:32:46 on Problem 1088
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int s[110][110];
int a[110][110];
int x[4]={0,0,1,-1};
int y[4]={-1,1,0,0};
int n,m;
int dfs(int px,int py)
{
    int i,tx,ty;
    for(i=0;i<4;i++)
    {
        tx=px+x[i];
        ty=py+y[i];
        if(tx>=0&&tx<n&&ty>=0&&ty<m)
        {
            if(s[tx][ty]>s[px][py]&&a[px][py]+1>a[tx][ty])
           {
               a[tx][ty]=a[px][py]+1;
                  dfs(tx,ty);
           }
        }
    }
}
int main()
{
    int i,j,mpp,ki,kj;
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++)
    for(j=0;j<m;j++)
  {
       scanf("%d",&s[i][j]);
         a[i][j]=1;
  }
     for(i=0;i<n;i++)
        for(j=0;j<m;j++)
            dfs(i,j);
        mpp=0;
       for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       if(mpp<a[i][j])
           mpp=a[i][j];
     printf("%d\n",mpp);
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