#include <bits/stdc++.h>
#include "wall.h"
using namespace std;
const int inf = 1e9;
const int N = 2e6+5;
int mn[4*N];
int mx[4*N];
int arr[N];
void applay(int node, int low, int up) {
mn[node] = max(mn[node], low);
mx[node] = max(mx[node], low);
mx[node] = min(mx[node], up);
mn[node] = min(mn[node], up);
}
void push(int node) {
applay(node*2,mn[node],mx[node]);
applay(node*2+1,mn[node],mx[node]);
mn[node] = 0;
mx[node] = inf;
}
void update(int node, int l, int r, int L, int R, int h, int op) {
if (l > R || r < L) return;
if (l >= L && r <= R) {
if (op == 1) applay(node,h,inf); else applay(node,0,h);
return;
}
push(node);
int mid = (l+r)/2;
update(node*2,l,mid,L,R,h,op);
update(node*2+1,mid+1,r,L,R,h,op);
}
void getans(int node, int l, int r) {
if (l == r) {
arr[l] = mx[node];
return;
}
push(node);
int mid = (l+r)/2;
getans(node*2,l,mid);
getans(node*2+1,mid+1,r);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
for (int i = 1; i <= 4*n; i++) {
mx[i] = 1e9;
mn[i] = 0;
}
for (int i = 0; i < k; i++) {
update(1,1,n,left[i]+1,right[i]+1,height[i],op[i]);
}
getans(1,1,n);
for (int i = 1; i <= n; i++) {
finalHeight[i-1] = arr[i];
}
return;
}
| # | 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... |