// compile: make data
// run: ./data < data.in
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#ifdef LOCAL
#include <debug/codeforces.h>
#define debug(x...) {_variables(#x);_print(x);}
#else
#define debug(x...)
#endif
template<typename...Args> void print_(Args...args){((cout<<args<<" "),...)<<endl;}
#define rep(i,a,b) for(int i=(a);i<(int)(b);++i)
#define sz(v) ((int)(v).size())
#define print(...) print_(__VA_ARGS__);
#define INTMAX (int)(9223372036854775807)
#define INTINF (int)(1152921504606846976)
#define int long long
#define MAXN 200010
int n, m;
vector<int> a;
struct node {
int s, minus, g;
vector<int> ban;
};
vector<node> f;
map<int, int> cnt;
int binary_search(vector<node> &a, int l, int r, int x) {
int ans = -1;
while (l <= r) {
int mid = l + (r-l) / 2;
if (a[mid].s > x) r = mid - 1;
else ans = mid, l = mid + 1;
}
return ans;
}
int sg(int x) {
int ind = binary_search(f, 0, sz(f)-1, x);
if (!~ind) return x;
// if (p) debug(x, ind, f[ind].s)
if (f[ind].s == x) return f[ind].g;
return x - f[ind].minus;
}
void init() {
int num = 0, maxsg = f[0].s - 1;
rep(i, 0, sz(f)) {
// debug(maxsg)
int minv = INTINF;
map<int, int> v;
for (auto j: f[i].ban) {
int t = sg(f[i].s - j);
++v[t];
}
for (auto [key, value]: v) {
if (cnt[key] + 1 == value) {
minv = key;
break;
}
}
if (minv != INTINF) {
++cnt[minv];
f[i].g = minv;
f[i].minus = ++num;
}
else {
f[i].g = ++maxsg;
f[i].minus = num;
}
// debug(f[i].s)
// ++cnt[f[i].g];
if (i+1 < sz(f) && f[i+1].s > f[i].s+1) maxsg = max(maxsg, f[i+1].s - f[i].minus - 1);
// int total = 0;
// for (auto j: f[i].ban) {
// if (sg(f[i].s - j) == minv) ++total;
// }
// // debug(minv, cnt[minv], total)
// // debug(maxsg)
// if (++cnt[f[i].g] == total) f[i].minus = ++num, f[i].g = minv;
// else {
// f[i].minus = num;
// f[i].g = maxsg + 1;
// }
// if (i+1 < sz(f) && f[i+1].s > f[i].s + 1) maxsg = f[i+1].s - f[i].minus - 1;
}
}
int32_t main() {
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
cin >> n >> m; a.resize(n);
rep(i, 0, n) cin >> a[i];
vector<pair<int, int>> t(m);
rep(i, 0, m) cin >> t[i].first >> t[i].second;
// auto cmp = [](const pair<int, int> &a, const pair<int, int> &b) {return a.first < b.first || (a.first == b.first && a.second > b.second); };
sort(t.begin(), t.end());
f.push_back({t[0].first, 0, 0, {t[0].second}});
rep(i, 1, m) {
if (t[i].first != t[i-1].first) f.push_back({t[i].first, 0, 0, {}});
f.rbegin()->ban.push_back(t[i].second);
}
init();
// debug(f[0].minus, f[1].minus, f[2].minus)
// sg(3, 121;
// rep(i, 0, 100) cout << sg(i) << endl;
// rep(i, 0, 20) debug(i, sg(i))
// debug(f[0].minus, f[1].minus, f[2].minus)
int ans = 0;
rep(i, 0, n) ans ^= sg(a[i]);
cout << (ans ? "Takahashi" : "Aoki") << endl;
return 0;
}
I’ve been placing bets on tr88bet recently. I’ve had a positive experience and the platform is user-friendly. I definitely recommend checking out tr88bet if you’re considering.
Calling all iOS users! 88vinproios looks like the go-to app for 88vin. If you’re on iPhone, this is a must-have. Go there NOW at 88vinproios!
I love the loyalty program on 37winbet. I’d recommend checking them out to see if you can also get perks such as free bets! Check it out: 37winbet
Love how easy it is to navigate the site. I managed to hit a decent jackpot last night and the credit went straight to my account. phjili01 is definitely a winner.
The login process is seamless and the mobile version works perfectly on my phone. It is refreshing to find a site that actually cares about the user experience. Visit phnn7770login
Walking into this site feels like stepping into a vibrant lounge where the excitement never stops. The welcome package gave me plenty of room to explore different categories without burning through my bankroll too quickly. I also love the daily cashback rewards that keep the momentum going even on slower days. It is definitely become my go to spot for weekend relaxation. pebrangocasino
The theme and the layout are just beautiful. It doesnt feel like a typical casino site. The gameplay is fluid and the wins feel earned. Cheers! phaeronplay
Alright, x03gamedownload. Just downloaded some stuff from here. Seemed legit, download was fast. No complaints so far. If you need some stuff, might be worth checking out. x03gamedownload
Guys, if you’re in Vietnam and feeling lucky, check out lucky888vietnam. The site’s got a bunch of cool games, and it feels very tailored for the local audience. Worth a look if you’re looking for a new place to try your luck. Go to: lucky888vietnam