제출 #1280847

#제출 시각아이디문제언어결과실행 시간메모리
1280847vache_kocharyanKlasika (COCI20_klasika)C++20
0 / 110
5092 ms2824 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; void dfs(int node, int parent, long long ans, bool B) { if (node == b)B = true; if (B) { answer = max(answer, ans); } for (auto &i : G[node]) { if (i.first == parent)continue; dfs(i.first, node, ans ^ i.second, B); } } 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 }); } else { int a, bb; cin >> a >> bb; b = bb; dfs(a, -1, 0, false); cout << answer << endl; answer = 0; } } 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...