Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
全部数据都过了,就是WA?郁闷了!#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator