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 int long long
const int M = 1e5 + 1;
int ans,xx,val[M];
vector<int> nei[M];
void dfs(int u)
{
ans=max(ans,val[u]^xx);
for (int i:nei[u])
dfs(i);
}
signed main()
{
int q;
cin>>q;
int nd=1;
while (q--)
{
string s;
cin>>s;
if (s=="Add")
{
int x,y;
cin>>x>>y;
val[++nd]=val[x]^y;
nei[x].push_back(nd);
}
else
{
int a,b;
cin>>a>>b;
ans=0,xx=val[a];
dfs(b);
cout<<ans<<endl;
}
}
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... |