| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:哪位大哥帮忙看看,为什么总是WA啊?In Reply To:哪位大哥帮忙看看,为什么总是WA啊? Posted by:xcl119xcl at 2006-02-20 15:14:11 > #include <iostream>
> using namespace std;
>
> int m,n,y,z,d[100][100];
>
> class skee
> {
> public:
>
> skee();
> void set(int ,int );
> void recursion();
> void compare();
> private:
> int a,b,ci,cj,c[100][100];
>
> };
>
> skee::skee()
> {
> for(int i=0;i<100;i++)
> {
> for(int j=0;j<100;j++)
> {
> c[i][j]=-1;
> }
> }
> }
>
> void skee::set(int a1,int b1)
> {
> a=a1;
> b=b1;
> for(int i=0;i<a;i++)
> {
> for(int j=0;j<b;j++)
> {
> int k;
> cin>>k;
> c[i][j]=k;
> d[i][j]=0;
> cout<<" ";
> }
> cout<<endl;
> }
>
> }
>
> void skee::recursion()
> {
>
> if(d[m][n]==0||y==0)
> {
> d[m][n]=1;
> y=1;
> }
>
> //向前
> if((ci-1)>=0&&cj<b&&c[ci][cj]>c[ci-1][cj])
> {
>
> if(d[ci-1][cj]!=0)
> {
> if((d[ci-1][cj]+y)>d[m][n])
> d[m][n]=y+d[ci-1][cj];
> }
> else
> {
> ++y;
> //d[m][n]=y;
> ci--;
> recursion();
> ci++;
> y--;
> }
> }
> //向右
> if((cj+1)<b&&ci>=0&&c[ci][cj]>c[ci][cj+1])
> {
>
> if(d[ci][cj+1]!=0)
> {
>
> if((d[ci][cj+1]+y)>d[m][n])
> d[m][n]=y+d[ci][cj+1];
> }
> else
> {
> ++y;
> //d[m][n]=y;
> cj++;
> recursion();
> cj--;
> y--;
> }
> }
> //向下
> if((ci+1)<a&&cj>=0&&c[ci][cj]>c[ci+1][cj])
> {
>
> if(d[ci+1][cj]!=0)
> {
>
> if((d[ci+1][cj]+y)>d[m][n])
> d[m][n]=y+d[ci+1][cj];
> }
> else
> {
> ++y;
> //d[m][n]=y;
>
> ci++;
> recursion();
> ci--;
> y--;
> }
> }
> //向左
> if((cj-1)>=0&&ci>=0&&c[ci][cj]>c[ci][cj-1])
> {
>
> if(d[ci][cj-1]!=0)
> {
> if((d[ci][cj-1]+y)>d[m][n])
> d[m][n]=y+d[ci][cj-1];
> }
> else
> {
> ++y;
> //d[m][n]=y;
> cj--;
> recursion();
> cj++;
> y--;
> }
> }
>
> }
>
> void skee::compare()
> {
> for(int i=0;i<a;i++)
> {
> for(int j=0;j<b;j++)
> {
> m=ci=i;
> n=cj=j;
> recursion();
> }
> }
>
> for(int i1=0;i1<a;i1++)
> {
> for(int j1=0;j1<b;j1++)
> {
>
> if(d[0][0]<d[i1][j1])
> d[0][0]=d[i1][j1];
> }
> }
> cout<<d[0][0];
> }
>
> void main()
> {
> int g,h;
> skee ren;
> while(cin>>g>>h)
> {
> ren.set(g,h);
> ren.compare();
> }
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator