【题目链接】
【思路要点】
- 补档博客,无题解。
【代码】
#include<bits/stdc++.h> using namespace std; #define MAXN 105 #define MAXV 405 int sg[MAXN][MAXN], mark[MAXV]; int n, T, num; bool func(int x, int y) { return x == 0 || y == 0 || x == y; } int main() { memset(sg, -1, sizeof(sg)); sg[1][2] = sg[2][1] = 0; for (int i = 0; i < MAXN; i++) for (int j = 0; j < MAXN; j++) { if (sg[i][j] != -1 || func(i, j)) continue; num++; for (int k = 1; k <= max(i, j); k++) { if (i >= k && !func(i - k, j)) mark[sg[i - k][j]] = num; if (j >= k && !func(i, j - k)) mark[sg[i][j - k]] = num; if (i >= k && j >= k && !func(i - k, j - k)) mark[sg[i - k][j - k]] = num; } int ans = 0; while (mark[ans] == num) ans++; sg[i][j] = ans; } scanf("%d", &T); while (T--) { scanf("%d", &n); int ans = 0, flg = false; for (int i = 1; i <= n; i++) { int x, y; scanf("%d%d", &x, &y); if (func(x, y)) flg = true; else ans ^= sg[x][y]; } if (ans || flg) printf("^o^\n"); else printf("T_T\n"); } return 0; }