# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1014495 | vjudge1 | Cake 3 (JOI19_cake3) | C++17 | 737 ms | 106824 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 lolwhy(l,r) (qry(rt[l],rt[r+1],m)-2*cake[r].first+2*cake[l].first)
vector<pair<int,int>> cake;
struct node{
int l,r,c;
long long v;
} T[1<<22];
int rt[1<<18],CC,CV;
int nn1(int a,int b){
T[++CC]={T[a].l,T[a].r,T[a].c+1,T[a].v+b};
return CC;
}
int nn2(int a,int b){
T[++CC]={a,b,T[a].c+T[b].c,T[a].v+T[b].v};
return CC;
}
long long qry(int l,int r,int k){
if(!r)return 0;
if(T[r].c-T[l].c==k)
return T[r].v-T[l].v;
if(T[T[r].r].c-T[T[l].r].c>k)
return qry(T[l].r,T[r].r,k);
return qry(T[l].l,T[r].l,k-T[T[r].r].c+
T[T[l].r].c)+T[T[r].r].v-T[T[l].r].v;
}
int ad(int i,int l,int r,int p,int v){
if(l==r)return nn1(i,v);
if(l+r>>1<p)return nn2(T[i].l,ad(T[i].r,l+r+2>>1,r,p,v));
return nn2(ad(T[i].l,l,l+r>>1,p,v),T[i].r);
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... |