Submission #844541

#TimeUsernameProblemLanguageResultExecution timeMemory
844541vjudge1Klasika (COCI20_klasika)C++17
33 / 110
5039 ms12492 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <bits/stdc++.h> using namespace std; #define int long long const int MAXN = 2e5 + 5; #define ONLINE_JUDGE #ifndef ONLINE_JUDGE #define OPEN freopen(".in", "r", stdin); \ freopen(".out", "w", stdout); #else #define OPEN void(23); #endif vector <pair <int, int>> adj[MAXN]; vector <pair <int, int>> radj[MAXN]; int cnt = 2; int FindAns(int a, int b) { vector <bool> sub(cnt + 5); function <void(int)> dfsSub = [&](int node) -> void { //cerr << node << " "; sub[node] = true; for(auto &[child, w] : adj[node]) dfsSub(child); return; }; dfsSub(b); int ans = 0; function <void(int, int, int)> dfs = [&](int node, int par, int sum) -> void { if(sub[node]) ans = max(ans, sum); for(auto &[child, w] : adj[node]) if(child != par) dfs(child, node, sum ^ w); for(auto &[child, w] : radj[node]) if(child != par) dfs(child, node, sum ^ w); }; dfs(a, 0, 0); return ans; } void solve() { int q; cin >> q; for(int i = 1; i <= q; i++) { string str; int a, b; cin >> str >> a >> b; if(str[0] == 'A') { adj[a].emplace_back(cnt, b); radj[cnt].emplace_back(a, b); cnt++; } else { cout << FindAns(a, b) << "\n"; } } return; } int32_t main() { OPEN; ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; //cin >> t; while(t--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...