Submission #769961

#TimeUsernameProblemLanguageResultExecution timeMemory
769961vjudge1Klasika (COCI20_klasika)C++17
0 / 110
259 ms9992 KiB
#include <bits/stdc++.h> #define ve vector #define vi vector<int> #define vii vector<ii> #define ii pair<int,int> #define fi first #define se second #define ll long long #define INF 1e9+7 #define pb push_back #define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) using namespace std; #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const int MOD = 1e9+7; const int nax = 2e5+5; void readio(){ #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } vii adj[nax]; int cnt = 0, tin[nax], tout[nax]; bool isAnc(int u, int v){ return (tin[u] <= tin[v] && tout[v] <= tout[u]); } void dfs(int u, int p){ tin[u] = cnt++; for(auto x : adj[u]){ if(x.fi == p ) continue; dfs(x.fi,u); } tout[u] = cnt++; } int srch(int u, int p,int cst, int sub){ int mx = 0; if(isAnc(sub, u)) { //cout << u << endl; mx = cst; } for(auto x : adj[u]){ if(x.fi == p) continue; mx = max(srch(x.fi,u, cst^x.se, sub), mx); } return mx; } int main() { optimise; //readio(); int q; cin >> q; for (int i = 1; i <= q; ++i) { string type; cin >> type; if(type == "Add"){ int x,y; cin >> x >> y; x--; adj[x].pb({i,y}); adj[i].pb({x,y}); } else { int a,b; cin >> a >> b; a--,b--; cnt = 0; dfs(0,0); cout << srch(a, -1, 0, b) << endl; } } }

Compilation message (stderr)

klasika.cpp: In function 'void readio()':
klasika.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
klasika.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen("output.txt", "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...