将序列差分并翻转之后,变成了阶梯(Nim)的模板题
QAQ
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define ri register int
#define rep(io, st, ed) for(ri io = st; io <= ed; io ++)
#define drep(io, ed, st) for(ri io = ed; io >= st; io --)
#define gc getchar
inline int read() {
int p = 0, w = 1; char c = gc();
while(c < '0' || c > '9') { if(c == '-') w = -1; c = gc(); }
while(c >= '0' && c <= '9') p = p * 10 + c - '0', c = gc();
return p * w;
}
int n;
int a[20050], d[20050];
int main() {
int T = read();
while(T --) {
int sg = 0;
n = read();
rep(i, 1, n) a[i] = read();
rep(i, 1, n) d[i] = a[i] - a[i - 1];
for(ri i = n; i >= 1; i -= 2) sg ^= d[i];
if(sg) printf("TAK
");
else printf("NIE
");
}
return 0;
}