| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 18444 | chan492811 | Weighting stones (IZhO11_stones) | C++98 | 76 ms | 79208 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <algorithm>
using namespace std;
int n,tn=1;
struct data{
int low,high,l,r,sum;
};
data tree[4000010];
void make_tree(int a){
if(a>=tn) return;
make_tree(a*2); make_tree(a*2+1);
if(tree[a*2].r==0) return;
if(tree[a*2+1].r==0){ tree[a]=tree[a*2]; return; }
tree[a].l=tree[a*2].l; tree[a].r=tree[a*2+1].r;
}
void update(int a,int l,int r,int plus){
if(tree[a].r<l || tree[a].l>r) return;
if(tree[a].l>=l && tree[a].r<=r){ tree[a].sum+=plus,tree[a].low+=plus,tree[a].high+=plus; return; }
update(a*2,l,r,plus); update(a*2+1,l,r,plus);
if(tree[a*2+1].r==0){ tree[a].low=tree[a*2].low; tree[a].high=tree[a*2].high; }
else { tree[a].low=min(tree[a*2].low,tree[a*2+1].low); tree[a].high=max(tree[a*2].high,tree[a*2+1].high); }
tree[a].low+=tree[a].sum; tree[a].high+=tree[a].sum;
}
int main(){
int i,a,s;
scanf("%d",&n); while(tn<n) tn*=2;
for(i=tn;i<tn+n;i++) tree[i].r=i-tn+1,tree[i].l=i-tn+1;
make_tree(1);
for(i=0;i<n;i++){
scanf("%d %d",&a,&s);
if(s==1) update(1,1,a,1);
else update(1,1,a,-1);
if(tree[1].low<0 && tree[1].high>0) printf("?\n");
else if(tree[1].high>0) printf(">\n");
else printf("<\n");
}
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
