Submission #769971

#TimeUsernameProblemLanguageResultExecution timeMemory
769971vjudge1Klasika (COCI20_klasika)C++17
0 / 110
5020 ms4680 KiB
//YOU WILL MAKE IT #pragma GCC optimize("Ofast") #pragma GCC target("avx2") #include<bits/stdc++.h> using namespace std; const int N=1e5+2; int ans=0; vector<pair<int,int>> graph[N]; int pa[N]; void dfs(int i,int j,int p,int cur,bool f){ if(f) ans=max(ans,cur); for(auto h:graph[i]){ int x=h.first; if((x==p)||(x==pa[j]&&f)) continue; dfs(x,j,i,cur^(h.second),(f|(x==j))); } } void solve(){ int q;cin>>q; int n=2; while(q--){ string s;cin>>s; int x,y;cin>>x>>y; if(s[0]=='A'){ graph[n].push_back({x,y}); graph[x].push_back({n,y}); pa[n]=x; n++; } else{ ans=0; dfs(x,y,-1,0,(x==y)); cout<<ans<<endl; } } } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); 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...