//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#define ordered_set tree<int, null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>
#define eps 1e-9
#define MOD1 998244353
#define MOD2 1000000007
#define INV_10 299473306
#define INF 1000000000
#define PI 3.14159265358979323846
using namespace std;
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
int p=1;
while(p <= n)
p*=2;
pair<int, int> max_tree[2*p+1], min_tree[2*p+1];
for(int i = 0; i < 2*p+1; i++)
max_tree[i]=make_pair(0, -1);
for(int i = 0; i < 2*p+1; i++)
min_tree[i]=make_pair(1000000, -1);
for(int i = 0; i < k; i++)
{
int x=left[i]+p, y=right[i]+p;
if(op[i]==1)
{
while(x <= y)
{
if(x%2==1)
{
max_tree[x]=max(max_tree[x], make_pair(h[i], i));
x++;
}
if(y%2==0)
{
max_tree[y]=max(max_tree[y], make_pair(h[i], i));
y++;
}
}
}
else
{
while(x <= y)
{
if(x%2==1)
{
min_tree[x]=min(min_tree[x], make_pair(height[i], -i));
x++;
}
if(y%2==0)
{
min_tree[y]=min(min_tree[y], make_pair(height[i], -i));
y++;
}
}
}
}
for(int i = 1; i <= n; i++)
{
int x=i+p;
pair<int, int> ma=make_pair(0, -1), mi=make_pair(1000000, -1);
while(x >= 1)
{
ma=max(ma, max_tree[x]);
mi=min(mi, min_tree[x]);
x/=2;
}
if(mi.first >= ma.first)
finalHeight[i]=ma.first;
else
{
if(mi.second*(-1) > ma.second)
finalHeight[i]=mi.first;
else
finalHeight[i]=ma.first;
}
}
}
//size
Compilation message
wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:32:45: error: 'h' was not declared in this scope
32 | max_tree[x]=max(max_tree[x], make_pair(h[i], i));
| ^
wall.cpp:37:45: error: 'h' was not declared in this scope
37 | max_tree[y]=max(max_tree[y], make_pair(h[i], i));
| ^