Submission #1095875

#TimeUsernameProblemLanguageResultExecution timeMemory
1095875rayan_bdKlasika (COCI20_klasika)C++17
33 / 110
5064 ms7672 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize("Ofast") #pragma GCC optimize("inline") #pragma GCC optimize("-fgcse") #pragma GCC optimize("-fgcse-lm") #pragma GCC optimize("-fipa-sra") #pragma GCC optimize("-ftree-pre") #pragma GCC optimize("-ftree-vrp") #pragma GCC optimize("-fpeephole2") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("-fsched-spec") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("-falign-jumps") #pragma GCC optimize("-falign-loops") #pragma GCC optimize("-falign-labels") #pragma GCC optimize("-fdevirtualize") #pragma GCC optimize("-fcaller-saves") #pragma GCC optimize("-fcrossjumping") #pragma GCC optimize("-fthread-jumps") #pragma GCC optimize("-funroll-loops") #pragma GCC optimize("-fwhole-program") #pragma GCC optimize("-freorder-blocks") #pragma GCC optimize("-fschedule-insns") #pragma GCC optimize("inline-functions") #pragma GCC optimize("-ftree-tail-merge") #pragma GCC optimize("-fschedule-insns2") #pragma GCC optimize("-fstrict-aliasing") #pragma GCC optimize("-fstrict-overflow") #pragma GCC optimize("-falign-functions") #pragma GCC optimize("-fcse-skip-blocks") #pragma GCC optimize("-fcse-follow-jumps") #pragma GCC optimize("-fsched-interblock") #pragma GCC optimize("-fpartial-inlining") #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("-freorder-functions") #pragma GCC optimize("-findirect-inlining") #pragma GCC optimize("-fhoist-adjacent-loads") #pragma GCC optimize("-frerun-cse-after-loop") #pragma GCC optimize("inline-small-functions") #pragma GCC optimize("-finline-small-functions") #pragma GCC optimize("-ftree-switch-conversion") #pragma GCC optimize("-foptimize-sibling-calls") #pragma GCC optimize("-fexpensive-optimizations") #pragma GCC optimize("-funsafe-loop-optimizations") #pragma GCC optimize("inline-functions-called-once") #pragma GCC optimize("-fdelete-null-pointer-checks") #define getar(ar,n) for(ll i=0;i<n;++i) cin>>ar[i] #define show(n) cout<<n<<'\n' #define all(v) v.begin(), v.end() #define br cout<<"\n" #define pb push_back #define nl '\n' #define yes cout<<"YES\n" #define no cout<<"NO\n" #define ret return #define ll long long #define ld long double #define sza(x) ((int)x.size()) const int mxN = 2e5 + 500; const ll MOD = 1e9 + 7; const ll INF = 1e9; const ld EPS = 1e-9; ll parent[mxN]; vector<pair<ll,ll>> adj[mxN]; ll x=0,ans=0; void from_u_to_v(ll u,ll v,ll par,ll xr){ if(u==v){ x=xr; return; } for(auto it:adj[u]){ if(it.first^par){ from_u_to_v(it.first,v,u,xr^it.second); } } } void get_maxima(ll u,ll xr){ ans=max(ans,x^xr); for(auto it:adj[u]){ if(it.first^parent[u]){ get_maxima(it.first,xr^it.second); } } } void assign_parent(ll u=1,ll par=-1){ parent[u]=par; for(auto it:adj[u]){ if(it.first^par){ assign_parent(it.first,u); } } } void solve() { ll n,u,v,tot=2;cin>>n; string str; for(ll i=0;i<n;++i){ cin>>str>>u>>v; x=ans=0; if(str=="Add"){ adj[u].pb({tot,v}); adj[tot].pb({u,v}); ++tot; }else if(str=="Query"){ from_u_to_v(u,v,-1,0); assign_parent(); get_maxima(v,0); show(ans); } } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); return 0; }

Compilation message (stderr)

klasika.cpp:25:39: warning: bad option '-fwhole-program' to pragma 'optimize' [-Wpragmas]
   25 | #pragma GCC optimize("-fwhole-program")
      |                                       ^
klasika.cpp:32:41: warning: bad option '-fstrict-overflow' to pragma 'optimize' [-Wpragmas]
   32 | #pragma GCC optimize("-fstrict-overflow")
      |                                         ^
klasika.cpp:34:41: warning: bad option '-fcse-skip-blocks' to pragma 'optimize' [-Wpragmas]
   34 | #pragma GCC optimize("-fcse-skip-blocks")
      |                                         ^
klasika.cpp:48:51: warning: bad option '-funsafe-loop-optimizations' to pragma 'optimize' [-Wpragmas]
   48 | #pragma GCC optimize("-funsafe-loop-optimizations")
      |                                                   ^
klasika.cpp:77:40: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
   77 | void from_u_to_v(ll u,ll v,ll par,ll xr){
      |                                        ^
klasika.cpp:77:40: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
klasika.cpp:77:40: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
klasika.cpp:77:40: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
klasika.cpp:90:27: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
   90 | void get_maxima(ll u,ll xr){
      |                           ^
klasika.cpp:90:27: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
klasika.cpp:90:27: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
klasika.cpp:90:27: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
klasika.cpp:99:36: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
   99 | void assign_parent(ll u=1,ll par=-1){
      |                                    ^
klasika.cpp:99:36: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
klasika.cpp:99:36: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
klasika.cpp:99:36: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
klasika.cpp:108:12: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
  108 | void solve() {
      |            ^
klasika.cpp:108:12: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
klasika.cpp:108:12: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
klasika.cpp:108:12: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
klasika.cpp:127:13: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
  127 | signed main() {
      |             ^
klasika.cpp:127:13: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
klasika.cpp:127:13: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
klasika.cpp:127:13: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...