是是非非
是是非非
https://ac.nowcoder.com/acm/problem/15519
nim博弈的基础上增加了修改,a ^ a = 0。
所以每次修改的时候我们先异或上a[x]再异或上y,最后把a[x]变成y。
判断异或和是不是0即可。
#include <bits/stdc++.h> #include <unordered_map> using namespace std; typedef long long ll; typedef unsigned long long ull; #ifdef LOCAL #define debug(x) cout << "[" __FUNCTION__ ": " #x " = " << (x) << "]\n" #define TIME cout << "RuningTime: " << clock() << "ms\n", 0 #else #define TIME 0 #endif #define hash_ 1000000009 #define Continue(x) { x; continue; } #define Break(x) { x; break; } const int mod = 998244353; const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3f; #define gc p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2) ? EOF : *p1++; inline int read(){ static char buf[1000000], *p1 = buf, *p2 = buf; register int x = false; register char ch = gc; register bool sgn = false; while (ch != '-' && (ch < '0' || ch > '9')) ch = gc; if (ch == '-') sgn = true, ch = gc; while (ch >= '0'&& ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = gc; return sgn ? -x : x; } ll fpow(ll a, int b, int mod) { ll res = 1; for (; b > 0; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } int a[N]; int main() { #ifdef LOCAL freopen("E:/input.txt", "r", stdin); #endif int n, q; cin >> n >> q; int sum = 0; for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sum ^= a[i]; while (q--) { int x, y; scanf("%d%d", &x, &y); sum = sum ^ a[x] ^ y; a[x] = y; if (sum != 0) puts("Kan"); else puts("Li"); } return TIME; }