Submission #1275906

#TimeUsernameProblemLanguageResultExecution timeMemory
1275906ayxanesedzade10원숭이와 사과 나무 (IZhO12_apple)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define all(x) x.begin(),x.end() using namespace std; const ll sz=1e6+100; ll st[4*sz],lazy[4*sz]; void push(ll l,ll r,ll ind) { if(lazy[ind]==0) return; st[ind]=r-l+1; if(l!=r){ lazy[2*ind]=1;lazy[2*ind+1]=1; } lazy[ind]=0;return; } void update(ll l,ll r,ll a,ll b,ll ind) { push(l,r,ind); if(l>b or r<a) return; if(l>=a and r<=b){ lazy[ind]=1;push(l,r,ind);return; } ll mid=(l+r)/2; update(l,mid,a,b,2*ind); update(mid+1,r,a,b,2*ind+1); st[ind]=st[2*ind]+st[2*ind+1]; } ll ask(ll l,ll r,ll a,ll b,ll ind) { push(l,r,ind); if(l>b or r<a) return 0; if(l>=a and r<=b) return st[ind]; ll mid=(l+r)/2; return ask(l,mid,a,b,2*ind)+ask(mid+1,r,a,b,2*ind+1); } int main() { ll m,n=1e6,c=0;cin>>m; for(int i=1;i<=m;i++){ ll d,x,y;cin>>d>>x>>y; if(d==1){ x=x+c;y=y+c; ll res=ask(1,n,x,y,1); cout<<res<<endl;c=ask(1,n,1,n,1); } else{ x=x+c;y=y+c; update(1,n,x,y,1); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...