Submission #1172867

#TimeUsernameProblemLanguageResultExecution timeMemory
1172867rayan_bdKlasika (COCI20_klasika)C++17
0 / 110
104 ms24248 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; #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()) #define fi first #define se second const int mxN = 3e5 + 5; const ll MOD = 1e9 + 7; const ll INF = 1e9; const ld EPS = 1e-9; ll cxor[mxN]; struct Node { Node* children[2]; Node(){ for(ll i=0;i<2;++i){ children[i]=NULL; } } }; struct Trie{ Node* root = new Node(); void add(ll x){ Node* curr=root; for(ll i=32;i>=0;--i){ ll curr_bit=(x&(1ll<<i))>0; if(curr->children[curr_bit]==NULL){ curr->children[curr_bit]=new Node(); } curr=curr->children[curr_bit]; } } ll qry(ll x){ Node* curr=root; ll ans=0; for(ll i=32;i>=0;--i){ ll curr_bit=(x&(1ll<<i))>0; if(curr->children[!curr_bit]!=NULL){ curr=curr->children[!curr_bit]; ans|=(1ll<<i); }else{ curr=curr->children[curr_bit]; } if(curr==NULL) break; } return ans; } } t; void lets_go() { ll q,x,y,n=1;cin>>q; string type; while(q--){ cin>>type>>x>>y; if(type=="Add"){ cxor[++n]=cxor[x]^y; t.add(cxor[n]); }else{ show(t.qry(cxor[x])); } } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); memset(cxor,0,sizeof(cxor)); lets_go(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...