LightOJ-1247 Matrix Game
每一行n个的石头块的数量之和为一堆,共m堆, 转化成普通nim博弈, 亦或求解。
#include <bits/stdc++.h>using namespace std;const int MAXN = 100;int main () {int t, n, m, x;int kase = 0;cin >> t;while (t--) {cin >> m >> n;int p = 0;for (int j = 0; j < n; j++) {cin >> x;p += x;}int status = p;for (int i = 1; i < m; i++) {p = 0;for (int j = 0; j < n; j++) {cin >> x;p += x;}status ^= p;}cout << "Case " << ++kase << ": " << (status == 0 ? "Bob" : "Alice") << "\n";}return 0;
}