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 yangjianfeng at 2012-04-08 11:09:40 on Problem 1088 and last updated at 2012-04-08 20:16:23
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
struct SK
{
  bool flag;
   int c;
   int h;
}s[103][103];
int a[10003];
int dir[4][2]={-1,0,1,0,0,-1,0,1};
int main()
{
   // freopen("in.txt","r",stdin);
   int i,j,r,c,f,x,y,l,max,m;
   bool flag;
   while(scanf("%d%d",&r,&c)!=EOF)
   {  memset(s,0,sizeof(s));
      memset(a,0,sizeof(a));
      for(i=1;i<=r;i++)
        for(j=1;j<=c;j++)
        {
           scanf("%d",&s[i][j].h);
            s[i][j].c=1;
            a[s[i][j].h]++;
        }
    m=0;
    for(f=10000;f>=0;f--)//这里开始时(f>0),少了个=号,所以错了!
    {
     while(a[f]--)
      {
        flag=1;
        for(i=1;i<=r&&flag;i++)
          for(j=1;j<=c&&flag;j++)
           if(!s[i][j].flag&&s[i][j].h==f)
              {flag=0;x=i;y=j;break;}
        s[x][y].flag=1;
        max=0;
         for(l=0;l<4;l++)
          {
             i=x+dir[l][0];
             j=y+dir[l][1];
            if(s[i][j].h<=s[x][y].h)
              continue;
            if(s[i][j].c>max)
               max=s[i][j].c;
         }
           s[x][y].c+=max;
           if(s[x][y].c>m)
            m=s[x][y].c;
      }
    }
    printf("%d\n",m);
   }
    return 0;
}
我自己发现问题了、、少了一个=号,这样会把h=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