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了,

Posted by dreamone at 2007-10-08 14:23:59 on Problem 1321
#include<iostream>
#include<algorithm>
using namespace std;
int value[8][8],i,j,n,m,ans;
bool usedx[8],usedy[8];
char ch;
void dfs(int x,int y,int su)
{
   if(usedx[x]==1||usedy[y]==1)
      return ;
   if(x<0||x>=n||y<0||y>=n)
      return ;
   if(value[x][y]==0)
     return ;
   su++;
   if(su==m)
   {
    ans++;
    return ;
   }
   usedx[x]=usedy[y]=1;
   for(i=x;i<n;i++)
     for(j=0;j<n;j++)
        dfs(i,j,su);
    usedx[x]=usedy[y]=0;
}
int main()
{

    while(cin>>n>>m)
    {
        if(n==-1&&m==-1)
           break;
        for(i=0;i<n;i++)
           for(j=0;j<n;j++)
            {
                cin>>ch;
                if(ch=='.')
                  value[i][j]=0;
                if(ch=='#')
                  value[i][j]=1;
            }
         ans=0;
         for(i=0;i<n;i++)
            for(j=0;j<n;j++)
            {
                if(value[i][j]==1)
                  dfs(i,j,0);
            }
         cout<<ans<<endl;
    }
    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