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

为什么WA~~哪位大牛帮我看下,WA一下午了

Posted by win163 at 2007-08-27 15:23:12 on Problem 1321
#include<stdio.h>
#define NO -1000000
char map[10][10];
long flag[10][10],count,n,tot,chek;
void search(long x,long y)
{
     long i,j,dx,dy,k;
     flag[x][y]=1;
     if(chek==tot)
      count++;
     else
     {
        for(i=x;i<n;i++)
        for(j=0;j<n;j++)
         if(!flag[i][j])
         {
           dx=i;
           dy=j;
           while(flag[dx][dy]==0&&dy<n) dy++;
           if(dy<n&&flag[dx][dy]==1) continue;
           dx=i;
           dy=j;
           while(flag[dx][dy]==0&&dy>=0) dy--;
           if(dy>=0&&flag[dx][dy]==1) continue;
           dx=i;
           dy=j;
           while(flag[dx][dy]==0&&dx<n) dx++;
             if(dx<n&&flag[dx][dy]==1) continue;
           dx=i;
           dy=j;
           while(flag[dx][dy]==0&&dx>=0) dx--;
             if(dx>=0&&flag[dx][dy]==1) continue;
           chek++;
           search(i,j);
           chek--;
           flag[i][j]=0;
         }
     }
}     
main()
{
      long need,i,j;
      while(EOF!=scanf("%ld%ld",&n,&tot))
      {
       if(n==-1&&tot==-1) break;
        for(i=0;i<n;i++)
        {
         scanf("%s",map[i]);
         for(j=0;j<n;j++)
         if(map[i][j]=='#') flag[i][j]=0;
         else flag[i][j]=NO;
        }
        count=0;
        for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        if(flag[i][j]==0)
        {
           chek=1;
          search(i,j); 
          flag[i][j]=0;
        }
      printf("%ld\n",count);
      }
}

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