Reprint Please specify source: http://blog.csdn.net/vmurder/article/details/42653921
In fact, I just feel that the original traffic is a bit more uncomfortable than unauthorized piracy 233 ...
Test instructions: to a direction-free graph (topological map), there are several pieces, two people in turn, each time you can take one of the pieces along the figure walk one step, unable to lose the operator.
Problem: SG function Bare topic, template question
Code:
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define N 1005using namespace Std;bool map[n][n];int n,q,d[n];int sg[n];void dfs (int x) {int I,j,k;bool vis[n]={0};for (i=0;i<n; i++) if (Map[x][i]) {if (sg[i]==-1) DFS (i); vis[sg[i]]=1;} for (i=0;vis[i];i++); Sg[x]=i;} int main () {//freopen ("test.in", "R", stdin), int i,j,k,a;while (scanf ("%d", &n)!=eof) {memset (map,0,sizeof (map)); memset (sg,-1,sizeof (SG)), for (i=0;i<n;i++) {scanf ("%d", &d[i]), and for (j=1;j<=d[i];j++) {scanf ("%d", &a); Map[i][a]=1;}} for (i=0;i<n;i++) if (sg[i]==-1) DFS (i), while (scanf ("%d", &q), q) {k=0;while (q--) {scanf ("%d", &a); k^=sg[a];} if (k) puts ("WIN"); else puts ("Lose");}} return 0;}
"POJ2425" A Chess game game, SG function, bare title, template title