#include <iostream>
using namespace std;
struct node{
int mn,mx;
};
const int MAXN = 4e6+5;
pair<int,int> lazy[4*MAXN];
int ans[MAXN];
node seg[4*MAXN];
void push(int curr,int l,int r){
auto temp = make_pair(0,0);
if(lazy[curr] == temp){
return;
}
if(l==r){
if(lazy[curr].first == 1){
if(seg[curr].mx <lazy[curr].second){
seg[curr].mx = lazy[curr].second;
seg[curr].mn = lazy[curr].second;
}
}else{
if(seg[curr].mx >lazy[curr].second){
seg[curr].mx = lazy[curr].second;
seg[curr].mn = lazy[curr].second;
}
}
return;
}
int mid = (l+r)/2;
if(lazy[2*curr]!=temp){
push(2*curr,l,mid);
}
if(lazy[2*curr+1]!=temp){
push(2*curr+1,mid+1,r);
}
seg[curr].mx = max(seg[2*curr].mx,seg[2*curr+1].mx);
seg[curr].mn = min(seg[2*curr].mn,seg[2*curr+1].mn);
if(lazy[curr].first == 1){
if(seg[curr].mn<lazy[curr].second){
lazy[2*curr] = make_pair(1,lazy[curr].second);
lazy[2*curr+1] = make_pair(1,lazy[curr].second);
seg[curr].mn = lazy[curr].second;
seg[curr].mx = max(seg[curr].mx,lazy[curr].second);
lazy[curr] = temp;
}
}else{
if(seg[curr].mx>lazy[curr].second){
lazy[2*curr] = make_pair(2,lazy[curr].second);
lazy[2*curr+1] = make_pair(2,lazy[curr].second);
seg[curr].mx = lazy[curr].second;
seg[curr].mn = min(seg[curr].mn,lazy[curr].second);
lazy[curr] = temp;
}
}
}
void build(int curr,int l,int r){
if(l==r){
seg[curr].mn = 0;
seg[curr].mx = 0;
return;
}
int mid = (l+r)/2;
build(2*curr,l,mid);
build(2*curr+1,mid+1,r);
seg[curr].mn = min(seg[2*curr].mn,seg[2*curr+1].mn);
seg[curr].mx = max(seg[2*curr].mx,seg[2*curr+1].mx);
}
void updateadd(int curr,int l,int r,int tl,int tr,int val){
push(curr,l,r);
if(l>tr||r<tl){
return;
}
if(l>=tl && r<=tr){
push(curr,l,r);
lazy[curr] = make_pair(1,val);
return;
}
int mid = (l+r)/2;
updateadd(2*curr,l,mid,tl,tr,val);
updateadd(2*curr+1,mid+1,r,tl,tr,val);
seg[curr].mn = min(seg[2*curr].mn,seg[2*curr+1].mn);
seg[curr].mx = max(seg[2*curr].mx,seg[2*curr+1].mx);
}
void updatedel(int curr,int l,int r,int tl,int tr,int val){
push(curr,l,r);
if(l>tr||r<tl){
return;
}
if(l>=tl && r<=tr){
push(curr,l,r);
lazy[curr] = make_pair(2,val);
return;
}
int mid = (l+r)/2;
updatedel(2*curr,l,mid,tl,tr,val);
updatedel(2*curr+1,mid+1,r,tl,tr,val);
seg[curr].mn = min(seg[2*curr].mn,seg[2*curr+1].mn);
seg[curr].mx = max(seg[2*curr].mx,seg[2*curr+1].mx);
}
void query(int curr,int l,int r){
push(curr,l,r);
if(l==r){
ans[l-1] = seg[curr].mx;
return;
}
int mid = (l+r)/2;
query(2*curr,l,mid);
query(2*curr+1,mid+1,r);
seg[curr].mn = min(seg[2*curr].mn,seg[2*curr+1].mn);
seg[curr].mx = max(seg[2*curr].mx,seg[2*curr+1].mx);
}
void buildWall(int n, int k, int op[], int left[], int right[],int height[], int finalHeight[]){
build(1,1,n);
for(int i=0;i<k;i++){
if(op[i] == 1){
updateadd(1,1,n,left[i]+1,right[i]+1,height[i]);
}else{
updatedel(1,1,n,left[i]+1,right[i]+1,height[i]);
}
}
query(1,1,n);
for(int i=0;i<n;i++){
finalHeight[i] = ans[i];
cout<<ans[i]<<endl;
}
}
int main(){
int n,k;
cin>>n>>k;
int left[k+1];
int right[k+1];
int height[k+1];
int type[k+1];
int finalHeight[k+1];
for(int i=0;i<k;i++){
cin>>type[i]>>left[i]>>right[i]>>height[i];
}
buildWall(n,k,type,left,right,height,finalHeight);
}
Compilation message
/tmp/ccnXoUgL.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc41Mxig.o:wall.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status