Submission #686666

#TimeUsernameProblemLanguageResultExecution timeMemory
686666Farhan_HYKlasika (COCI20_klasika)C++14
33 / 110
5061 ms438548 KiB
#include <bits/stdc++.h> #define int long long #define F first #define S second #define T int t; cin >> t; while(t--) #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); using namespace std; const int N = 1e6 + 5; const int M = 1e3 + 3; const int inf = 1e18; const int mod = 1e9 + 7; int q, ans; vector<pair<int, int>> adj[N]; set<int> st[N]; void dfs(int node, int from, int with, int b) { if (st[node].find(b) != st[node].end()) ans = max(ans, with); for(auto x: adj[node]) { if (x.F != from) dfs(x.F, node, with ^ x.S, b); } } main() { IOS cin >> q; int cnt = 1; st[1].insert(1); while(q--) { string s; int a, b; cin >> s >> a >> b; if (s[0] == 'A') { adj[a].push_back({++cnt, b}); adj[cnt].push_back({a, b}); for(auto x: st[a]) st[cnt].insert(x); st[cnt].insert(cnt); } else { ans = 0; dfs(a, 0, 0, b); cout << ans << '\n'; } } }

Compilation message (stderr)

klasika.cpp:26:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   26 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...