Submission #581031

#TimeUsernameProblemLanguageResultExecution timeMemory
581031AGEKlasika (COCI20_klasika)C++14
33 / 110
5042 ms27920 KiB
#include<bits/stdc++.h> #define F first #define S second #define int long long #define pb push_back using namespace std; const int N=1e6,M=2e3,mod=1e9+7; pair<int,pair<int,int> > a[N]; int ans[N],p[N]; vector<int>adj[N]; int mux=-1e18; void dfs(int node,int par,int a){ mux=max(mux,ans[node]^ans[a]); for(auto x:adj[node]){ if(x==par) continue; dfs(x,node,a); } } main() { int q; cin>>q; ans[1]=0; int num=2; p[1]=0; while(q--){ string s; cin>>s; if(s=="Add"){ int x,y; cin>>x>>y; adj[x].pb(num); ans[num]=ans[x]^y; p[num]=x; num++; } else{ int x,y; cin>>x>>y; mux=-1e18; dfs(y,p[y],x); cout<<mux<<endl; } /*for(int i=1;i<num;i++){ cout<<i<<": "; for(auto x:adj[i]) cout<<x<<" "; cout<<endl;*/ } return 0; }

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...