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 |
关于这题,很无语!!!1WA的代码:#include"stdio.h" #include"string.h" int g[1001][1001],sg[1001],flag[1001]; int n,m,num; void dfs(int p) { int i; memset(flag,0,sizeof(flag)); for(i=0;i<n;i++) { if(g[p][i]) { if(sg[i]==-1) { dfs(i); flag[sg[i]]=1; } else { flag[sg[i]]=1; } } } for(i=0;i<n;i++) if(flag[i]==0) { sg[p]=i; break; } } int main() { int i,j,temp,res; while(scanf("%d",&n)!=EOF) { memset(g,0,sizeof(g)); memset(sg,0xff,sizeof(sg)); for(i=0;i<n;i++) { scanf("%d",&num); for(j=0;j<num;j++) { scanf("%d",&temp); g[i][temp]=1; } } for(i=0;i<n;i++) if(sg[i]==-1) dfs(i); while(scanf("%d",&m),m!=0) { res=0; for(i=0;i<m;i++) { scanf("%d",&temp); res=res^sg[temp]; } if(res==0) printf("LOSE\n"); else printf("WIN\n"); } } return 0; } 之后把flag数组改为在dfs函数里面定义,如下: void dfs(int p) { int i; bool flag[1001]={false}; 结果AC了 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator