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>
using namespace std;
#define ll long long
#define ar array
const int mxN=2e5;
int n=1, val[mxN];
vector<int> adj[mxN];
int dfs(int u, int x) {
int MX=x^val[u];
for (int v: adj[u]) {
MX=max(MX, dfs(v, x));
}
return MX;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int q; cin >> q;
while(q--) {
string type; cin >> type;
int a, b; cin >> a >> b;
if (type=="Add") {
--a;
val[n]=val[a]^b;
adj[a].push_back(n);
++n;
}
if (type=="Query") {
--a, --b;
cout << dfs(b, val[a]) << "\n";
}
}
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... |