이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int Nmax = 2e5 + 10;
int sz;
struct node {
    int to[2];
    set <int> s;
} trie[Nmax * 31];
void add(int x, int ti) {
    int u = 0;
    for (int i = 29; i >= 0; --i) {
        if (!trie[u].to[x >> i & 1]) trie[u].to[x >> i & 1] = ++sz;
        u = trie[u].to[x >> i & 1];
        trie[u].s.insert(ti);
    }
}
int get(int x, int L, int R) {
    int u = 0;
    int ans = 0;
    for (int i = 29; i >= 0; --i) {
        auto iter = trie[trie[u].to[x >> i & 1 ^ 1]].s.lower_bound(L);
        if (iter == trie[trie[u].to[x >> i & 1 ^ 1]].s.end() || *iter > R) u = trie[u].to[x >> i & 1];
        else ans += (1 << i), u = trie[u].to[x >> i & 1 ^ 1];
    }
    return ans;
}
int q;
vector <pair <int, int> > e[Nmax];
int in[Nmax], out[Nmax], ti, d[Nmax];
void dfs(int u) {
    in[u] = ++ti;
    for (auto [v, w]: e[u]) {
        d[v] = d[u] ^ w;
        dfs(v);
    }
    out[u] = ti;
}
vector <tuple <string, int, int> > queries;
int main() {
    ios :: sync_with_stdio(0); cin.tie(0); 
    cin >> q;
    int n = 1;
    while (q--) {
        string s;
        int x, y;
        cin >> s >> x >> y;
        if (s == "Add") ++n, e[x].push_back({n, y}), queries.push_back({s, n, y});
        else queries.push_back({s, x, y});
    }
    dfs(1);
    add(d[1], in[1]);
    for (auto [s, x, y]: queries) {
        if (s == "Add") add(d[x], in[x]);
        else cout << get(d[x], in[y], out[y]) << '\n';
    }
}
컴파일 시 표준 에러 (stderr) 메시지
klasika.cpp: In function 'int get(int, int, int)':
klasika.cpp:26:44: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   26 |         auto iter = trie[trie[u].to[x >> i & 1 ^ 1]].s.lower_bound(L);
      |                                     ~~~~~~~^~~
klasika.cpp:27:44: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   27 |         if (iter == trie[trie[u].to[x >> i & 1 ^ 1]].s.end() || *iter > R) u = trie[u].to[x >> i & 1];
      |                                     ~~~~~~~^~~
klasika.cpp:28:53: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   28 |         else ans += (1 << i), u = trie[u].to[x >> i & 1 ^ 1];
      |                                              ~~~~~~~^~~| # | 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... |