大概知道要记搜,但是为啥
我感觉我爆搜复杂度没问题吧
#include <bits/stdc++.h>
#define gt getchar
#define pt putchar
#define ll int
using namespace std;
const int MAXN = 20;
ll read() {
ll x = 0, f = 1;char ch = gt();
while (ch < '0' || ch > '9') {if (ch == '-') f = -1;ch = gt();}
while (ch >= '0' && ch <= '9') {x *= 10;x += ch - '0';ch = gt();}
return x * f;
}
ll n;
ll a[MAXN], b[MAXN];
bool f[MAXN];//第i张牌选没选过
//1为高桥胜,0为青木胜
inline bool dfs(ll x) {
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
if(!f[i] && !f[j] && (a[i] == a[j] || b[i] == b[j])) {
f[i] = f[j] = true;
ll p = dfs(~ x);
if(p == (x & 1)) {
f[i] = f[j] = false;
return x & 1;
}
f[i] = f[j] = false;
}
}
}
if(x & 1) return 0;
return 1;
}
int main() {
n = read();
for (int i = 1; i <= n; i++) {
a[i] = read(), b[i] = read();
}
if(dfs(1)) cout << "Takahashi\n";
else cout << "Aoki\n";
return 0;
}