Submission #1277535

#TimeUsernameProblemLanguageResultExecution timeMemory
1277535k12_khoiMonkey and Apple-trees (IZhO12_apple)C++17
0 / 100
135 ms123004 KiB
#include <bits/stdc++.h> using namespace std; const int N=1e7+5; int n,request,type,u,v,res; int t[4*N]; void down(int id,int l,int r) { if (t[id]==r-l+1) { int m=(l+r)/2; t[id*2]=m-l+1; t[id*2+1]=r-m; } } void update(int id,int l,int r) { if (u>r or v<l) return; if (u<=l and v>=r) { t[id]=r-l+1; return; } down(id,l,r); int m=(l+r)/2; update(id*2,l,m); update(id*2+1,m+1,r); t[id]=t[id*2]+t[id*2+1]; } int get(int id,int l,int r) { if (u>r or v<l) return 0; if (u<=l and v>=r) return t[id]; down(id,l,r); int m=(l+r)/2; return get(id*2,l,m)+get(id*2+1,m+1,r); } int main() { ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); n=1e7; res=0; cin >> request; while (request--) { cin >> type >> u >> v; u+=res; v+=res; if (type==1) { res=get(1,1,n); cout << res << '\n'; } else update(1,1,n); } }
#Verdict Execution timeMemoryGrader output
Fetching results...