#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define all(c) (c).begin(), (c).end()
const int N = 1e5 + 5;
vector<int> adj[N],xr(N);
int res;
void dfs(int node,int val){
res = max(res,val ^ xr[node]);
for(int go : adj[node]){
dfs(go,val);
}
}
void solve(){
int q;
cin >> q;
int cnt = 1;
for(int i = 0; i < q; i++){
string s; cin >> s;
int x,y; cin >> x >> y;
if(s[0] == 'A'){
adj[x].push_back(++cnt);
xr[cnt] = xr[x] ^ y;
}
else{
res = 0;
dfs(y,xr[x]);
cout << res << endl;
}
}
}
signed main(){
#ifndef ONLINE_JUDGE
// freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
// cin >> t;
while(t--){
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
3416 KB |
Output is correct |
2 |
Correct |
1 ms |
3416 KB |
Output is correct |
3 |
Correct |
1 ms |
3416 KB |
Output is correct |
4 |
Correct |
1 ms |
3416 KB |
Output is correct |
5 |
Correct |
1 ms |
3416 KB |
Output is correct |
6 |
Correct |
1 ms |
3416 KB |
Output is correct |
7 |
Correct |
2 ms |
3416 KB |
Output is correct |
8 |
Correct |
2 ms |
3420 KB |
Output is correct |
9 |
Correct |
1 ms |
3416 KB |
Output is correct |
10 |
Correct |
1 ms |
3416 KB |
Output is correct |
11 |
Correct |
1 ms |
3416 KB |
Output is correct |
12 |
Correct |
2 ms |
3416 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
3416 KB |
Output is correct |
2 |
Correct |
1 ms |
3416 KB |
Output is correct |
3 |
Correct |
1 ms |
3416 KB |
Output is correct |
4 |
Correct |
1 ms |
3416 KB |
Output is correct |
5 |
Correct |
1 ms |
3416 KB |
Output is correct |
6 |
Correct |
1 ms |
3416 KB |
Output is correct |
7 |
Correct |
2 ms |
3416 KB |
Output is correct |
8 |
Correct |
2 ms |
3420 KB |
Output is correct |
9 |
Correct |
1 ms |
3416 KB |
Output is correct |
10 |
Correct |
1 ms |
3416 KB |
Output is correct |
11 |
Correct |
1 ms |
3416 KB |
Output is correct |
12 |
Correct |
2 ms |
3416 KB |
Output is correct |
13 |
Correct |
2 ms |
3416 KB |
Output is correct |
14 |
Correct |
3 ms |
3416 KB |
Output is correct |
15 |
Correct |
3 ms |
3672 KB |
Output is correct |
16 |
Correct |
3 ms |
3672 KB |
Output is correct |
17 |
Correct |
2 ms |
3416 KB |
Output is correct |
18 |
Correct |
2 ms |
3416 KB |
Output is correct |
19 |
Correct |
2 ms |
3416 KB |
Output is correct |
20 |
Correct |
1 ms |
3420 KB |
Output is correct |
21 |
Correct |
2 ms |
3416 KB |
Output is correct |
22 |
Correct |
2 ms |
3420 KB |
Output is correct |
23 |
Correct |
2 ms |
3612 KB |
Output is correct |
24 |
Correct |
2 ms |
3416 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5092 ms |
6024 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
3416 KB |
Output is correct |
2 |
Correct |
1 ms |
3416 KB |
Output is correct |
3 |
Correct |
1 ms |
3416 KB |
Output is correct |
4 |
Correct |
1 ms |
3416 KB |
Output is correct |
5 |
Correct |
1 ms |
3416 KB |
Output is correct |
6 |
Correct |
1 ms |
3416 KB |
Output is correct |
7 |
Correct |
2 ms |
3416 KB |
Output is correct |
8 |
Correct |
2 ms |
3420 KB |
Output is correct |
9 |
Correct |
1 ms |
3416 KB |
Output is correct |
10 |
Correct |
1 ms |
3416 KB |
Output is correct |
11 |
Correct |
1 ms |
3416 KB |
Output is correct |
12 |
Correct |
2 ms |
3416 KB |
Output is correct |
13 |
Correct |
2 ms |
3416 KB |
Output is correct |
14 |
Correct |
3 ms |
3416 KB |
Output is correct |
15 |
Correct |
3 ms |
3672 KB |
Output is correct |
16 |
Correct |
3 ms |
3672 KB |
Output is correct |
17 |
Correct |
2 ms |
3416 KB |
Output is correct |
18 |
Correct |
2 ms |
3416 KB |
Output is correct |
19 |
Correct |
2 ms |
3416 KB |
Output is correct |
20 |
Correct |
1 ms |
3420 KB |
Output is correct |
21 |
Correct |
2 ms |
3416 KB |
Output is correct |
22 |
Correct |
2 ms |
3420 KB |
Output is correct |
23 |
Correct |
2 ms |
3612 KB |
Output is correct |
24 |
Correct |
2 ms |
3416 KB |
Output is correct |
25 |
Execution timed out |
5092 ms |
6024 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |