# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
224252 | jamielim | Klasika (COCI20_klasika) | C++14 | 2907 ms | 441540 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
const int MAXN=200005;
const int BITS=30;
int n=1,q,ctr=1;
pair<int,pair<int,int> > query[MAXN];
vector<pair<int,int> > adj[MAXN];
int l[MAXN],r[MAXN],x[MAXN]; //discovery, finish, xor from root
struct trie{
set<int> s;
trie *z,*o;
trie(){z=o=NULL;}
void add(int h,int v,int idx){ //h: height, number of bits; v: value at subtree root; idx: discovery index being added
s.insert(idx);
if(h<0)return;
if(v&(1<<h)){
if(o==NULL)o=new trie();
o->add(h-1,v,idx);
}else{
if(z==NULL)z=new trie();
z->add(h-1,v,idx);
}
}
int get(int h,int v,int fr,int to){ //h: height, number of bits; v: value of query node; [fr,to): range allowed
if(h<0)return 0;
if((v&(1<<h))==0){ //want 1
if(o==NULL||o->s.lower_bound(fr)==o->s.upper_bound(to))return z->get(h-1,v,fr,to);
return (1<<h)+o->get(h-1,v,fr,to);
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |