hdu 1524 A Chess Game 博弈论
2013-08-29 16:03
281 查看
SG函数!!
代码如下:
View Code
代码如下:
#include<stdio.h> #include<cstring> #define I(x) scanf("%d",&x) int map[1005][1005],sg[1005]; int getsg(int n) { if(sg !=-1) return sg ; if(!map [0]) return sg =0; bool vis[1001]; memset(vis,0,sizeof(vis)); for(int i=1;i<=map [0];i++) vis[getsg(map [i])]=1; int i=0; while(vis[i]) i++; return sg =i; } int main(){ int i,t,n,s,k,j,m; while(I(n)!=EOF){ for(i=0;i<n;i++){ I(map[i][0]); for(j=1;j<=map[i][0];j++) I(map[i][j]); } memset(sg,-1,sizeof(sg)); while(I(m)&&m){ s=0; for(i=0;i<m;i++){ I(k); s^=getsg(k); } puts(s?"WIN":"LOSE"); } } return 0; }
View Code
相关文章推荐
- POJ 2425 && HDU 1524 A Chess Game(博弈论)
- HDU 1524 A Chess Game(SG博弈)
- (step 8.2.13)hdu 1524(A Chess Game)
- hdu 1524 A Chess Game
- hdu1524 A Chess Game
- hdu 1524 A Chess Game
- SG 函数 hdu1524 & poj 2425 hdu1524 A Chess Game
- (step 8.2.13)hdu 1524(A Chess Game)
- hdu 1524 A Chess Game
- 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函数模板题)
- HDU 1524 A Chess Game [SG函数]【博弈】
- hdu 1524 A Chess Game (SG)
- HDU_1524 A Chess Game (sg函数)
- HDU 1524 - A Chess Game(SG)
- hdu 2486/2580 / poj 3922 A simple stone game 博弈论
- HDU 5724 Chess(博弈论)