Submission #1282180

#TimeUsernameProblemLanguageResultExecution timeMemory
1282180vache_kocharyanKlasika (COCI20_klasika)C++20
Compilation error
0 ms0 KiB
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> #include <random> #include <chrono> #include <unordered_set> using namespace std; typedef long long ll; #define UNIQUE_SORT(vec) do { \ sort((vec).begin(), (vec).end()); \ (vec).erase(unique((vec).begin(), (vec).end()), (vec).end()); \ } while(0) #define yes cout << "YES" << endl #define no cout << "NO" << endl #define MIN(v) *min_element(all(v)) #define MAX(v) *max_element(all(v)) #define LB(c, x) distance((c).begin(), lower_bound(all(c), (x))) #define UB(c, x) distance((c).begin(), upper_bound(all(c), (x))) #define ss second #define ff first #define all(X) X.begin(), X.end() #define rall(X) X.rbegin(), X.rend() #define cinall(X) for(auto &i:X)cin >> i #define printall(X) for(auto &i:X)cout << i const int N = 2e5 + 5; struct Trie { int g[30 * N2][2], cnt[30 * N2], root = 1, new_g = 1; void add(int x) { int cur_node = root; for (int i = 30; i >= 0; i--) { int bit = (x >> i) & 1; if (g[cur_node][bit] == 0) { g[cur_node][bit] = ++new_g; } cur_node = g[cur_node][bit]; cnt[cur_node]++; } } void del(int x) { int cur_node = root; for (int i = 30; i >= 0; i--) { int bit = (x >> i) & 1; cur_node = g[cur_node][bit]; cnt[cur_node]--; } } int query(long long x) { int cur_node = root, ans = 0; for (int i = 30; i >= 0; i--) { int bit = (x >> i) & 1; if (g[cur_node][1 - bit] && cnt[g[cur_node][1 - bit]]) { ans += (1 << i); cur_node = g[cur_node][1 - bit]; } else { cur_node = g[cur_node][bit]; } } return ans; } }trie; vector<pair<int, int>>G[N]; int par[N]; int xxor[N]; void solve() { trie.add(0); int q; cin >> q; int cnt = 1; while (q--) { string s; cin >> s; if (s == "Add") { int x; long long y; cin >> x >> y; cnt++; G[x].push_back({ cnt, y }); G[cnt].push_back({ x, y }); par[cnt] = x; xxor[cnt] = xxor[x] ^ y; } else { int a, b; cin >> a >> b; cout << trie.query(xxor[a]) << endl; } } } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { solve(); cout << endl; } return 0; }

Compilation message (stderr)

klasika.cpp:32:20: error: 'N2' was not declared in this scope; did you mean 'N'?
   32 |         int g[30 * N2][2], cnt[30 * N2], root = 1, new_g = 1;
      |                    ^~
      |                    N
klasika.cpp:32:37: error: 'N2' was not declared in this scope; did you mean 'N'?
   32 |         int g[30 * N2][2], cnt[30 * N2], root = 1, new_g = 1;
      |                                     ^~
      |                                     N
klasika.cpp: In member function 'void Trie::add(int)':
klasika.cpp:39:29: error: 'g' was not declared in this scope
   39 |                         if (g[cur_node][bit] == 0)
      |                             ^
klasika.cpp:43:36: error: 'g' was not declared in this scope
   43 |                         cur_node = g[cur_node][bit];
      |                                    ^
klasika.cpp:44:25: error: 'cnt' was not declared in this scope; did you mean 'int'?
   44 |                         cnt[cur_node]++;
      |                         ^~~
      |                         int
klasika.cpp: In member function 'void Trie::del(int)':
klasika.cpp:54:36: error: 'g' was not declared in this scope
   54 |                         cur_node = g[cur_node][bit];
      |                                    ^
klasika.cpp:55:25: error: 'cnt' was not declared in this scope; did you mean 'int'?
   55 |                         cnt[cur_node]--;
      |                         ^~~
      |                         int
klasika.cpp: In member function 'int Trie::query(long long int)':
klasika.cpp:66:29: error: 'g' was not declared in this scope
   66 |                         if (g[cur_node][1 - bit] && cnt[g[cur_node][1 - bit]])
      |                             ^
klasika.cpp:66:53: error: 'cnt' was not declared in this scope; did you mean 'int'?
   66 |                         if (g[cur_node][1 - bit] && cnt[g[cur_node][1 - bit]])
      |                                                     ^~~
      |                                                     int