Submission #769992

#TimeUsernameProblemLanguageResultExecution timeMemory
769992vjudge1Klasika (COCI20_klasika)C++17
33 / 110
93 ms1080 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define vi vector<int> #define ve vector #define ll long long #define vl vector<ll> #define vll vector<pair<ll,ll>> #define onbit __builtin_popcount #define ii pair<int,int> #define vvi vector<vi> #define vii vector<ii> #define gii greater<ii> #define pb push_back #define mp make_pair #define fi first #define se second #define INF 1e18 #define eps 1e-7 #define eps1 1e-2 #define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define MAX_A 1e5+5 using namespace std; using namespace __gnu_pbds; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const ll MOD = 1e9+9; const int nax = 2e3+5; const int MAX_VAL = 1e6; double PI=3.14159265359; int arx[8]={1,1,0,-1,-1,-1, 0, 1}; int ary[8]={0,1,1, 1, 0,-1,-1,-1}; void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } vii adj[nax]; int parent[nax]; bool test=false; int dis; int res=0; int mx=0; void dfs(int x,int p) { if (test) return; for(auto u:adj[x]) { if (u.fi==p) continue; if (test) return; res^=u.se; if (u.fi==dis) { test=true; return; } dfs(u.fi,x); if (test) return; res^=u.se; } } void dfs2(int x,int p) { for(auto u:adj[x]) { if (u.fi==p) continue; res^=u.se; mx=max(mx,res); dfs2(u.fi,x); res^=u.se; } } int main(){ optimise; /*#ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif*/ //setIO("redistricting"); int q; cin>>q; int cnt=1; parent[0]=-1; while(q--) { string c; cin>>c; test=false; if(c[0]=='A'){ int x,y; cin>>x>>y; x--; parent[cnt]=x; adj[cnt].pb({x,y}); adj[x].pb({cnt,y}); cnt++; }else{ int x,y; cin>>x>>y; x--;y--; dis=y; res=0; if (x!=y) dfs(x,-1); mx=res; dfs2(y,parent[y]); cout<<mx<<endl; } } }

Compilation message (stderr)

klasika.cpp: In function 'void setIO(std::string)':
klasika.cpp:33:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
klasika.cpp:34:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...