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~~哪位大牛帮我看下,WA一下午了#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator