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 TheNull at 2004-10-26 19:39:08 on Problem 1088
不知道是不是算法错了?
#include <cstdio>
int fuv(int* z[],int p)
{
    if(z[p][1]>=0)
        return(z[p][1]);
    
    int t=0,q;
    for(q=2;q<6;q++)
    {
        int r;
        if(z[p][q]>=0&&z[p][0]>z[z[p][q]][0])
            r=fuv(z,z[p][q]);
        t=(r>t)?r:t;
    }
    z[p][1]=t+1;
    return(z[p][1]);
}
int main()
{
        int n,m;
        scanf("%d%d",&n,&m);
        int** c=new int* [n*m];
        
        int i,j,k;
        for(i=0,k=0;i<n;i++)
        {
            for(j=0;j<m;j++)
            {
                c[k]=new int[6];
                scanf("%d",&c[k][0]);
                c[k][1]=-1;
                c[k][2]=k-m;
                c[k][3]=(j==0)?-1:k-1;
                c[k][4]=(j==m-1)?-1:k+1;
                c[k][5]=(i==n-1)?-1:k+m;
                k++;
            }
        }
    
        j=0;
        for(i=0;i<k;i++)
        {
            int h=fuv(c,i);
            j=(h>j)?h:j;
        }

        printf("%d",j);

        for(i=0;i<k;i++)
        {
            delete [] c[i];
        }
        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