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

Re:((a[i][j]-a[i+x[p]][j+y[p]]==1) ?? >0吧

Posted by first at 2003-12-11 19:08:24 on Problem 1088
In Reply To:dp.....WA了, 检查了无数遍,找不到错。麻烦大家看一看好吗? Posted by:carlis at 2003-12-11 11:28:21
> #include <iostream>
> using namespace std;
> const int x[4]={1,-1,0,0},y[4]={0,0,1,-1};
> int main()
> {
>     int rep,i,j,p,r,c,a[101][101],l[101][101];
>     cin>>r>>c;
>     for(i=0;i<r;i++)for(j=0;j<c;j++){cin>>a[i][j];l[i][j]=0;}
>     for(;;){
>     rep=0;
>     for(i=0;i<r;i++)for(j=0;j<c;j++){
>         for(p=0;p<4;p++)if(i+x[p]>=0&&i+x[p]<r&&j+y[p]>=0&&j+y[p]<c)
>                 if((a[i][j]-a[i+x[p]][j+y[p]]==1)&&(l[i][j]+1>l[i+x[p]][j+y[p]])){
>                                 l[i+x[p]][j+y[p]]=l[i][j]+1;rep=1;
>                 }
>     }
>     if(!rep)break;
>     }
>     rep=0;
>     for(i=0;i<r;i++)for(j=0;j<c;j++)if(l[i][j]>rep)rep=l[i][j];
>     cout<<rep+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