제출 #670052

#제출 시각아이디문제언어결과실행 시간메모리
670052FerThugGato12500원숭이와 사과 나무 (IZhO12_apple)C++98
100 / 100
325 ms203464 KiB
#include<bits/stdc++.h> using namespace std; const int lmt = 1e5 + 5; struct Nodo{ int v, ls, rs; bool lazy; Nodo(){ v = lazy = ls = rs = 0; } }; Nodo st[lmt * 64 * 2]; int t=2; void update(Nodo &A, int v){ if(A.ls==0){ A.ls = t++; A.rs = t++; } if(!A.lazy) return; A.v = v; st[A.ls].lazy = st[A.rs].lazy = true; A.lazy=false; return; } int query(int tmp, int l, int r, int ini = 0, int fin = 1e9){ Nodo &A = st[tmp]; update(A, (fin-ini)+1); if(ini>r || fin<l) return 0; if(ini>=l && fin<=r){ return A.v; } int mit = (ini+fin)/2; return query(A.ls, l, r, ini, mit) + query(A.rs, l, r, mit+1, fin); } void insert(int tmp, int l, int r, int ini = 0, int fin = 1e9){ Nodo &A = st[tmp]; update(A, (fin-ini)+1); if(ini>r || fin<l) return; if(ini>=l && fin<=r){ A.v = (fin-ini)+1; A.lazy = -1; return; } int mit = (ini+fin)/2; insert(A.ls, l, r, ini, mit); insert(A.rs, l, r, mit+1, fin); A.v = st[A.ls].v + st[A.rs].v; return; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int q; cin>>q; long long c = 0; while(q--){ int z, x, y; cin>>z>>x>>y; x+=c; y+=c; if(z==1){ cout << (c = query(1,x,y)) << "\n"; }else{ insert(1,x,y); } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

apple.cpp: In constructor 'Nodo::Nodo()':
apple.cpp:8:23: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
    8 |         v = lazy = ls = rs = 0;
      |                    ~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...