제출 #1277536

#제출 시각아이디문제언어결과실행 시간메모리
1277536k12_khoi원숭이와 사과 나무 (IZhO12_apple)C++17
0 / 100
165 ms155680 KiB
#include <bits/stdc++.h> using namespace std; const int N=1e7+5; int n,request,type,u,v,res; int t[4*N]; bool lazy[4*N]; void down(int id,int l,int r) { if (lazy[id]) { lazy[id*2]=1; lazy[id*2+1]=1; int m=(l+r)/2; t[id*2]=m-l+1; t[id*2+1]=r-m; lazy[id]=0; } } 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; lazy[id]=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...