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

抱着必TEL 之心···居然随便就能过···晕··第一次搜索 蒙着写 居然过····无限汗····

Posted by s2009zy at 2010-03-31 23:14:25 on Problem 1088
#include <iostream>
using namespace std;
int a[1000][1000]={0};
int b[1000][1000]={0};
int c[1000][1000]={0};
int it,jt;
int p,q;
void serch(int i,int j)
{
    b[i][j]=1;
    if(a[i][j]<a[i][j+1])
    {
        if(b[i][j+1]!=1)
        {
       //     b[i][j+1]=1;
            serch(i,j+1);

        }
        if(c[i][j+1]+1>c[i][j])
        {
            c[i][j]=c[i][j+1]+1;
        }
    }
    if(a[i][j]<a[i][j-1])
    {
        if(b[i][j-1]!=1)
        {
         //    b[i][j-1]=1;
            serch(i,j-1);

        }
        if(c[i][j-1]+1>c[i][j])
        {
            c[i][j]=c[i][j-1]+1;
        }
    }
    if(a[i][j]<a[i+1][j])
    {
        if(b[i+1][j]!=1)
        {
        //     b[i+1][j]=1;
            serch(i+1,j);

        }
        if(c[i+1][j]+1>c[i][j])
        {
            c[i][j]=c[i+1][j]+1;
        }
    }
    if(a[i][j]<a[i-1][j])
    {
        if(b[i-1][j]!=1)
        {
        //    b[i-1][j]=1;
            serch(i-1,j);

        }
        if(c[i-1][j]+1>c[i][j])
        {
            c[i][j]=c[i-1][j]+1;
        }
    }
}
int main()
{
    int m,n;
    int min=10000;
    int mark1,mark2;
    cin>>m>>n;
        for(it=1;it<=m;it++)
        {
           for(jt=1;jt<=n;jt++)
           {
               cin>>a[it][jt];
               if(a[it][jt]<min)
               {
                   mark1=it;
                   mark2=jt;
               }
           }
        }
         for(it=1;it<=m;it++)
         {
            for(jt=1;jt<=n;jt++)
            {
                b[it][jt]=0;
            }
         }
        for(q=1;q<=m;q++)
        {
            for(p=1;p<=n;p++)
            {
                if(b[q][p]!=1)
                {
                   serch(q,p);
                }
            }
        }

        int max=0;
        for(it=1;it<=m;it++)
        {
            for(jt=1;jt<=n;jt++)
            {
                if(c[it][jt]>max)
                {
                    max=c[it][jt];
                }
            //    cout<<c[it][jt];
            }
        //    cout<<endl;
         }
         cout<<max+1<<endl;
}

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