Submission #30566

#TimeUsernameProblemLanguageResultExecution timeMemory
30566inqrWall (IOI14_wall)C++14
0 / 100
286 ms103592 KiB
#include "wall.h" #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define rt insert #define st first #define nd second #define ll long long #define pii pair < int , int > #define DB printf("debug\n"); #define umax( x , y ) x = max( x , (y) ) #define umin( x , y ) x = min( x , (y) ) #define all(x) x.begin() , x.end() using namespace std; int N; //add 1 erase 2 struct node{ int a,e,l; node(){a=-1,e=1e9,l=-1;} }; struct up{ int l,r,v,t; }; node st[8000005]; void merge(node &nod,up &u){ //printf(" nod a%d e%d l%d up v%d t%d\n",nod.a,nod.e,nod.l,u.v,u.t); if(nod.l==-1){// nod yapilmamis if(u.t==1){// update add nod.a=u.v; nod.l=1; } else{// nod.e=u.v; nod.l=2; } return; } if(u.t==1){// udate add DB if(nod.l==1){// node last add if(nod.a<u.v){// u add > node add nod.a=u.v; } else return;// u add < node add } else{//node last erase if(nod.e<u.v){// u add > node erase nod.l=1; nod.a=u.v; } else return;// u add < node erase } } else{// udate erase if(nod.l==1){//node last add if(u.v<nod.a){// u erase < node add nod.l=2; nod.e=u.v; } else return; } else{//node last erase if(u.v<nod.e){// u erase < node erase nod.e=u.v; } return; } } } void stup(up u,int l,int r,int stp){ if(l>r||u.r<l||r<u.l)return; //printf("ul%d ur%d uv%d ut%d l%d r%d stp%d\n",u.l,u.r,u.v,u.t,l,r,stp); if(st[stp].l!=-1&&l!=r){ //printf(" lzp l%d r%d\n",l,r); st[stp*2+1]=st[stp*2+2]=st[stp]; node a;st[stp]=a; } if(u.l<=l&&r<=u.r){ merge(st[stp],u); //printf(" a=%d e=%d l=%d\n",st[stp].a,st[stp].e,st[stp].l); return; } int m=(l+r)/2; stup(u,l,m,stp*2+1);stup(u,m+1,r,stp*2+2); } int que(int ql,int qr,int l,int r,int stp){ if(l>r||qr<l||r<ql)return -1; if(st[stp].l!=-1&&l!=r){ //printf(" lzp\n"); st[stp*2+1]=st[stp*2+2]=st[stp]; node a;st[stp]=a; } if(ql<=l&&r<=qr){ if(st[stp].l==-1)return 0; else if(st[stp].l==1)return st[stp].a; else return st[stp].e; } int m=(l+r)/2; return max(que(ql,qr,l,m,stp*2+1),que(ql,qr,m+1,r,stp*2+2)); } void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){ N=n; //cout<<k<<endl; for(int i=0;i<k;i++){ up u;u.l=left[i],u.r=right[i],u.v=height[i],u.t=op[i]; stup(u,0,n-1,0); } for(int i=0;i<n;i++){ finalHeight[i]=que(i,i,0,n-1,0); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...