제출 #701772

#제출 시각아이디문제언어결과실행 시간메모리
701772EthanKim8683원숭이와 사과 나무 (IZhO12_apple)C++17
0 / 100
13 ms5932 KiB
#include<bits/stdc++.h> using namespace std; using I=int; using Lli=long long int; using B=bool; const I Q=1e5; const I LOGP=30; const Lli FIXP=1ll<<LOGP; I chds[2*Q+1][2]; I vals[2*Q+1]; B dels[2*Q+1]; I t=1; void psh(Lli low,Lli upp,I j){ if(upp-low>1){ chds[j][0]=chds[j][0]?:++t,chds[j][1]=chds[j][1]?:++t; if(dels[j])vals[chds[j][0]]=vals[chds[j][1]]=(upp-low)/2; dels[chds[j][0]]|=dels[j],dels[chds[j][1]]|=dels[j]; } dels[j]=0; } void pll(Lli low,Lli upp,I j){ vals[j]=vals[chds[j][0]]+vals[chds[j][1]]; } void upd(Lli l,Lli r,Lli low=-FIXP,Lli upp=FIXP,I j=1){ if(l>=upp||r<=low)return; if(l<=low&&r>=upp){vals[j]=upp-low,dels[j]=1;return;} Lli mid=low+(upp-low)/2; psh(low,upp,j); upd(l,r,low,mid,chds[j][0]=chds[j][0]?:++t); upd(l,r,mid,upp,chds[j][1]=chds[j][1]?:++t); pll(low,upp,j); } I qry(Lli l,Lli r,Lli low=-FIXP,Lli upp=FIXP,I j=1){ if(l>=upp||r<=low)return 0; if(l<=low&&r>=upp)return vals[j]; Lli mid=low+(upp-low)/2; psh(low,upp,j); I res=0; res+=qry(l,r,low,mid,chds[j][0]=chds[j][0]?:++t); res+=qry(l,r,mid,upp,chds[j][1]=chds[j][1]?:++t); return res; } I main(){ cin.tie(0)->sync_with_stdio(0); I q;cin>>q; Lli c=0; while(q--){ I t;cin>>t; if(t==1){ Lli l,r;cin>>l>>r; c=qry(l+c,r+c+1); printf("%i\n",c); } if(t==2){ Lli l,r;cin>>l>>r; upd(l+c,r+c+1); } } }

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

apple.cpp: In function 'I main()':
apple.cpp:52:16: warning: format '%i' expects argument of type 'int', but argument 2 has type 'Lli' {aka 'long long int'} [-Wformat=]
   52 |       printf("%i\n",c);
      |               ~^    ~
      |                |    |
      |                int  Lli {aka long long int}
      |               %lli
#Verdict Execution timeMemoryGrader output
Fetching results...