//#pragma GCC optimize("O3,unroll-loops,Ofast")
//#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#include "wall.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define MAX 2000005
#define pb push_back
#define mp make_pair
#define int long long
#define f first
#define s second
#define vi vector<int>
#define pii pair<int,int>
#define si set<int>
#define vpii vector<pair<int,int>>
const int mod = 1e9+7;
const int INF = 1e18;
// myMap.begin()->first : key
// myMap.begin()->second : value
int epow(int a,int b){int ans=1;while(b){if(b&1) ans*=a;a*=a;b>>=1;ans%=mod;a%=mod;}return (ans+mod)%mod;}
int gcd(int a,int b) {if(a<b)swap(a,b);while(b){int tmp=b;b=a%b;a=tmp;}return a;}
int mul(int a,int b){return ((a%mod)*(b%mod))%mod;}
int sum(int a,int b){return ((a%mod)+(b%mod))%mod;}
// typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
// typedef
// tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_multiset;
int n,d;
vi arr(MAX);
struct segItem{
int val,lazymin,lazymax;
};
struct SegTree{
// segItem tree[MAX*4];
int mn[MAX*4],mx[MAX*4];
SegTree(){
memset(mn,-1,sizeof(mn));
memset(mx,-1,sizeof(mx));
}
void push(int v){
if(mn[v]!=-1){
if(mn[v*2]==-1) mn[v*2]=mn[v];
else mn[v*2]=max(mn[v*2],mn[v]);
if(mn[v*2+1]==-1) mn[v*2+1]=mn[v];
else mn[v*2+1]=max(mn[v*2+1],mn[v]);
if(mx[v*2]!=-1) mx[v*2]=max(mx[v*2],mn[v]);
if(mx[v*2+1]!=-1) mx[v*2+1]=max(mx[v*2+1],mn[v]);
}
if(mx[v]!=-1){
if(mx[v*2]==-1) mx[v*2]=mx[v];
else mx[v*2]=min(mx[v*2],mx[v]);
if(mx[v*2+1]==-1) mx[v*2+1]=mx[v];
else mx[v*2+1]=min(mx[v*2+1],mx[v]);
if(mn[v*2]!=-1) mn[v*2]=min(mn[v*2],mx[v]);
if(mn[v*2+1]!=-1) mn[v*2+1]=min(mn[v*2+1],mx[v]);
}
mn[v]=mx[v]=-1;
}
void updatemax(int v,int tl,int tr,int l ,int r,int val){
if(tl>tr || tl>r || tr<l) return;
if(tl>=l && tr<=r){
if(mx[v]==-1) mx[v]=val;
else mx[v]=min(mx[v],val);
if(mn[v]!=-1) mn[v]=min(mn[v],val);
return;
}
push(v);
int mid=(tl+tr)>>1;
updatemax(v*2,tl,mid,l,r,val); updatemax(v*2+1,mid+1,tr,l,r,val);
}
void updatemin(int v,int tl,int tr,int l ,int r,int val){
if(tl>tr || tl>r || tr<l) return;
if(tl>=l && tr<=r){
if(mn[v]==-1) mn[v]=val;
else mn[v]=max(mn[v],val);
if(mx[v]!=-1) mx[v]=max(mx[v],val);
return;
}
push(v);
int mid=(tl+tr)>>1;
updatemin(v*2,tl,mid,l,r,val); updatemin(v*2+1,mid+1,tr,l,r,val);
}
void query(int v,int tl,int tr){
if(tl==tr) {arr[tl-1]=max(mn[v],0LL);return;}
int mid=(tl+tr)>>1;
push(v);
query(v*2,tl,mid); query(v*2+1,mid+1,tr);
}
};
SegTree segtree;
void buildWall(int32_t N, int32_t k, int32_t op[], int32_t left[], int32_t right[], int32_t height[], int32_t finalHeight[]){
n = N;
for(int i=0;i<k;i++){
if(op[i]==1) segtree.updatemin(1,1,n,left[i]+1,right[i]+1,height[i]);
else segtree.updatemax(1,1,n,left[i]+1,right[i]+1,height[i]);
}
arr.resize(n);
segtree.query(1,1,n);
// for(int i=1;i<=n;i++) cout<<arr[i]<<endl;
return arr;
}
Compilation message
wall.cpp: In function 'void buildWall(int32_t, int32_t, int32_t*, int32_t*, int32_t*, int32_t*, int32_t*)':
wall.cpp:122:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
122 | return arr;
| ^~~