【灭鼠先锋 / B】
题目
代码
#include <bits/stdc++.h>
using namespace std;
unordered_map<string, bool> m;
bool check(string s)
{return count(s.begin(), s.end(), 'O') == 1;
}
bool SG(string s)
{if (m.count(s))return m[s];if (check(s))return m[s] = false;for (int i = 0; i < 8; i++){if (s[i] != 'O')continue;string tmp = s;tmp[i] = 'X';if (!SG(tmp))return m[s] = true;}for (int i = 0; i < 2; i++){for (int j = 0; j + 1 < 4; j++){int k = i * 4 + j;if (s[k] != 'O' || s[k + 1] != 'O')continue;string tmp = s;tmp[k] = 'X', tmp[k + 1] = 'X';if (!SG(tmp))return m[s] = true;}}return m[s] = false;
}
int main()
{string s[4] = {"XOOOOOOO", "XXOOOOOO", "OXOOOOOO", "OXXOOOOO"};for (int i = 0; i < 4; i++){if (SG(s[i]))cout << 'L';elsecout << 'V';}return 0;
}
注意
给定的字符串是小蓝操作后的结果,是小乔行动时的环境,我们计算的态属于小乔,因此取反。