Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=1524
1#include <stdio.h>2#include <cstring>3 using namespacestd;4 Const intM =10000000;//5 Const intN =1005;6 intSg[n], head[n];7 intCNT;8 9 structnode{Ten int from; One intto ; A intNext; - }edge[m]; - the voidAddedge (int from,intTo ) { -EDGE[CNT]. from= from; -Edge[cnt].to =to ; -Edge[cnt].next = head[ from];//edges from the same parent node +head[ from] = cnt++; - } + A voidinit () { atCNT =0;//total number of sides -memset (head,-1,sizeof(head)); -memset (sg,-1,sizeof(SG)); - } - - intMexintN) { in BOOLG[n]; -Memset (G,false,sizeof(g)); to if(Sg[n]! =-1 ) + returnSg[n]; - for(inti = head[n];i! =-1; i =Edge[i].next) { the if(Sg[edge[i].to] = =-1 ) *Sg[edge[i].to] =Mex (edge[i].to); $G[sg[edge[i].to]] =true;Panax Notoginseng } - for(inti =0; i < N; ++i) the if(!G[i]) + returni; A } the + intMain () { - intN, M, tmp; $ while(~SCANF ("%d",&N)) { $ init (); - for(inti =0; I < n; ++i) { -scanf"%d",&m); the for(intj =0; J < M; ++j) { -scanf"%d",&tmp);WuyiAddedge (I,TMP);//Building Map the } - } Wu while(~SCANF ("%d", &m) &&m) { - intAns =0; About for(inti =0; I < m; ++i) { $scanf"%d",&tmp); -Ans = ans ^MEX (TMP); - } -Puts (ans?)"WIN":"lose"); A } + } the return 0; -}
Hundred Questions Souvenir
"Hdoj 1524 A Chess Game" (DFS + SG function application)