# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1150257 | nikolashami | Index (COCI21_index) | C++20 | 1175 ms | 97244 KiB |
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll N=2e5,N2=5+24*N;
ll root[N2],lc[N2],rc[N2],st[N2],nd;
void bd(ll lik,ll l=1,ll r=N){
if(l==r)return;
lc[lik]=++nd;
rc[lik]=++nd;
bd(lc[lik],l,(l+r)/2);
bd(rc[lik],(l+r)/2+1,r);
}
void upd(ll pr,ll tr,ll id,ll l=1,ll r=N){
if(l==r){st[tr]=1+st[pr];return;}
ll md=(l+r)/2;
if(id<=md){
rc[tr]=rc[pr];
lc[tr]=++nd;
upd(lc[pr],lc[tr],id,l,md);
}else{
lc[tr]=lc[pr];
rc[tr]=++nd;
upd(rc[pr],rc[tr],id,md+1,r);
}
st[tr]=st[lc[tr]]+st[rc[tr]];
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |