This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |