Submission #212056

#TimeUsernameProblemLanguageResultExecution timeMemory
212056NONAMEKlasika (COCI20_klasika)C++17
33 / 110
5056 ms9584 KiB
#include <bits/stdc++.h> #define all(x) x.begin(),x.end() #define PB push_back using namespace std; typedef long long ll; const int N = 200100; const int M = 1000100; const int oo = 1e9; vector<int> g[N]; string qr; int pr[N], kol, xr[N], ans, q; void dfs(int v, int vl){ ans = max(ans, xr[v] ^ vl); for (int u : g[v]) dfs(u, vl); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); // freopen("in.txt","r",stdin); cin >> q; pr[0] = -1; xr[0] = 0; kol = 1; for (; q; q--){ cin >> qr; if (qr[0] == 'Q'){ int x, y; cin >> x >> y; x--; y--; ans = 0; dfs(y, xr[x]); cout << ans << '\n'; } else { int x, y; cin >> x >> y; x--; pr[kol] = x; xr[kol] = xr[x] ^ y; g[x].PB(kol); kol++; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...