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

Re:全部数据都过了,就是WA?郁闷了!哪位大哥帮帮我啊

Posted by majiaN at 2008-05-27 20:39:25 on Problem 1321
In Reply To:全部数据都过了,就是WA?郁闷了! Posted by:majiaN at 2008-05-27 20:38:47
> #include <cstdlib>
> #include <iostream>
> using namespace std;
> int step,x,y,flagx[10],flagy[10];char c[10][10];
> void dfs(int i)
> {int j,k;
>  for(k=0;k<x;k++)//x为行数,y为棋子数,i为现在步数,k为现在行数 y-i= x-1-k 
>  for(j=0;j<x;j++)
>  if(c[k][j]=='#'&&flagx[k]==0&&flagy[j]==0&&(y-i)<(x-k)) 
>  {
>   flagx[k]=flagy[j]=1;
>   if(i<y) dfs(i+1);
>   else step++;
>   flagx[k]=flagy[j]=0;
>  }
>  return ;
>  }
> int main(int argc, char *argv[])
> {   int i;
>     while(scanf("%d%d",&x,&y)!=EOF&&(x!=-1||y!=-1))
>     { step=0;
>       for(i=0;i<x;i++)
>       {flagx[i]=flagy[i]=0;
>       scanf("%*c%s",c[i]);
>       }
>       dfs(1);
>       printf("%d\n",step);
>     }
>     system("PAUSE");
>     return EXIT_SUCCESS;
> }

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