This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/** * * * * * * * * * * * * * * **\
* *
* Author: Haidara Nassour *
* Coded in: 2021\09\12 HH:MM:SS *
* Lang: C++ *
* *
\** * * * * * * * * * * * * * * **/
#include<bits/stdc++.h>
#include<wall.h>
#define rep(i,x,n) for(int i=x;i<n;i++)
#define FOR(i,n) rep(i,0,n)
using namespace std;
const int maxn=2000200;
int n;
struct node
{
int mintall=0,lazy=0;
}st[maxn*4];
int ul,ur,val;
void pu(int inx)
{
st[inx].mintall=min(st[inx*2].mintall,st[inx*2+1].mintall);
}
void pull(int inx,int l,int r)
{
if(st[inx].lazy<0)
{
if(st[inx].mintall>(-1)*st[inx].lazy)
st[inx].mintall=st[inx].lazy*(-1);
}
else
{
if(st[inx].mintall<st[inx].lazy)
st[inx].mintall=st[inx].lazy;
}
if(l!=r&&st[inx].lazy!=0)
{
st[inx*2].lazy=st[inx].lazy;
st[inx*2+1].lazy=st[inx].lazy;
}
st[inx].lazy=0;
}
void update(int l=1,int r=n,int inx=1)
{
pull(inx,l,r);
if(ul<=l&&r<=ur)
{
st[inx].lazy=val;
pull(inx,l,r);
return ;
}
if(ul>r||l>ur)
return ;
int mid=l+(r-l)/2;
update(l,mid,inx*2);
update(mid+1,r,inx*2+1);
pu(inx);
}
int query(int pos,int l=1,int r=n,int inx=1)
{
pull(inx,l,r);
if(l==r)
return st[inx].mintall;
int mid=l+(r-l)/2;
if(pos<=mid)
return query(pos,l,mid,inx*2);
return query(pos,mid+1,r,inx*2+1);
}
void buildWall(int sz, int k, int op[], int left[], int right[],
int height[], int finalHeight[])
{
n=sz;
FOR(i,k)
{
val=height[i];
left[i]++;
right[i]++;
ul=left[i];
ur=right[i];
if(op[i]>1)
val*=-1;
update();
}
FOR(i,n)
finalHeight[i]=query(i+1);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |