Submission #13232

#TimeUsernameProblemLanguageResultExecution timeMemory
13232dohyun0324Weighting stones (IZhO11_stones)C++98
100 / 100
64 ms8112 KiB
#include<stdio.h> #include<algorithm> using namespace std; int n,x,y,t=1,p; struct data { int maxi,mini,ch; }tree[600010]; void update(int x,int y,int k,int s,int e) { if(tree[k].ch!=0) { tree[k].maxi+=tree[k].ch; tree[k].mini+=tree[k].ch; tree[k*2].ch+=tree[k].ch; tree[k*2+1].ch+=tree[k].ch; tree[k].ch=0; } if(s<=x && y<=e) { tree[k].maxi+=p; tree[k].mini+=p; tree[k*2].ch+=p; tree[k*2+1].ch+=p; return; } if(s>y || e<x) return; update(x,(x+y)/2,k*2,s,e); update((x+y)/2+1,y,k*2+1,s,e); tree[k].maxi=max(tree[k*2].maxi,tree[k*2+1].maxi); tree[k].mini=min(tree[k*2].mini,tree[k*2+1].mini); } int main() { int i; scanf("%d",&n); for(;;){if(t>=n) break; t*=2;} for(i=1;i<=n;i++) { scanf("%d %d",&x,&y); if(y==1) p=1; else p=-1; update(1,t,1,1,x); if(tree[1].maxi<=0) printf("<\n"); else if(tree[1].mini>=0) printf(">\n"); else printf("?\n"); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...