제출 #1280856

#제출 시각아이디문제언어결과실행 시간메모리
1280856vache_kocharyanKlasika (COCI20_klasika)C++20
33 / 110
5087 ms2404 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; vector<pair<int, long long>>G[N]; #define UNIQUE_SORT(vec) do { \ sort((vec).begin(), (vec).end()); \ (vec).erase(unique((vec).begin(), (vec).end()), (vec).end()); \ } while(0) long long b, answer = 0; bool is[N]; int par[N]; void dfs(int node, int parent, long long ans) { if (is[node]) { answer = max(answer, ans); } for (auto &i : G[node]) { if (i.first == parent)continue; dfs(i.first, node, (ans ^ i.second)); } } void dfs1(int node, int parent) { is[node] = true; for (auto i : G[node]) { if (i.first != parent) dfs1(i.first, node); } } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(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; } else { int a, bb; cin >> a >> bb; b = bb; dfs1(bb, par[bb]); dfs(a, -1, 0); cout << answer << "\n"; answer = 0; for (int i = 1; i <= cnt; i++) is[i] = false; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...