hdu 1524 A Chess Game
2013-05-26 22:10
239 查看
\\Time 31ms, Memory 4312K
#include<iostream> #include<cstring> #include<cstdio> using namespace std; int n,p[1010][1010],sg[1010],b[1010]; int mex(int x) { if(sg[x]!=-1) return sg[x]; if(b[x]==0) return 0; int i,v[1010]; memset(v,0,sizeof(v)); for(i=0;i<b[x];i++) { sg[p[x][i]]=mex(p[x][i]); v[sg[p[x][i]]]=1; } for(i=0;;i++) if(!v[i]) return i; } int main() { int m; while(scanf("%d",&n)==1) { for(int i=0;i<n;i++) { scanf("%d",&b[i]); for(int j=0;j<b[i];j++) { scanf("%d",&p[i][j]); } } memset(sg,-1,sizeof(sg)); while(scanf("%d",&m)==1 && m) { int ans=0,a; for(int i=0;i<m;i++) { scanf("%d",&a); if(sg[a]==-1) sg[a]=mex(a); ans^=sg[a]; } if(ans) printf("WIN\n"); else printf("LOSE\n"); } } return 0; }
相关文章推荐
- hdu 1524 A Chess Game
- SG 函数 hdu1524 & poj 2425 hdu1524 A Chess Game
- HDU 1524 A Chess Game (有向无环图SG博弈)
- hdu 1524 A Chess Game
- HDU 1524 A Chess Game(SG函数)
- hdu 1524 A Chess Game (SG)
- (step 8.2.13)hdu 1524(A Chess Game)
- HDU 1524 A Chess Game 【SG函数】
- POJ 2425 && HDU 1524 A Chess Game(博弈论)
- hdu1524 A Chess Game
- hdu 1524 A Chess Game 博弈论
- (step 8.2.13)hdu 1524(A Chess Game)
- HDU 1524 - A Chess Game(SG)
- hdu 1524 A Chess Game
- HDU 1524 A Chess Game [SG函数]【博弈】
- HDU 1524 A Chess Game(SG博弈)
- HDU 1524 A Chess Game (SG函数模板题)
- HDU_1524 A Chess Game (sg函数)
- 杭电1524 A Chess Game(博弈--- 图)
- sg函数_____A Chess Game( hdu 2425 )