#include <bits/stdc++.h>
#include<unordered_map>
#include<algorithm>
using namespace std;
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
struct node {
int mx = 0, mn = 0;
};
node tree[2 * (1 << 21) + 20];
vector<int> ans(2000005);
void lazy(int pos) {
tree[2 * pos].mn = min(tree[2 * pos].mn, tree[pos].mn);
tree[2 * pos].mn = max(tree[2 * pos].mn, tree[pos].mx);
tree[2 * pos].mx = min(tree[2 * pos].mx, tree[pos].mn);
tree[2 * pos].mx = max(tree[2 * pos].mx, tree[pos].mx);
tree[2 * pos + 1].mn = min(tree[2 * pos + 1].mn, tree[pos].mn);
tree[2 * pos + 1].mn = max(tree[2 * pos + 1].mn, tree[pos].mx);
tree[2 * pos + 1].mx = min(tree[2 * pos + 1].mx, tree[pos].mn);
tree[2 * pos + 1].mx = max(tree[2 * pos + 1].mx, tree[pos].mx);
return;
}
void update(int tree_index, int tl, int tr, int l, int r, int type, int heigh) {
if (tr<l || tl>r) return;
if (tl <= l && r >= tr) {
if (type == 1) {
tree[tree_index].mn = max(tree[tree_index].mn, heigh);
tree[tree_index].mx = max(tree[tree_index].mx, heigh);
}
else {
tree[tree_index].mn = min(tree[tree_index].mn, heigh);
tree[tree_index].mx = min(tree[tree_index].mx, heigh);
}
return;
}
lazy(tree_index);
tree[tree_index].mn = 2000010;
tree[tree_index].mx = 0;
update(tree_index * 2, tl, (tl + tr) / 2, l, r, type, heigh);
update(tree_index * 2 + 1, (tl + tr) / 2 + 1, tr, l, r, type, heigh);
}
void get(int l, int r, int tree_index) {
if (l == r) {
ans[l] = tree[tree_index].mn;
}
lazy(tree_index);
get(l, (l + r) / 2, tree_index * 2);
get((l + r) / 2 + 1, r, tree_index * 2 + 1);
}
void buildWall(int n, int k, int* op, int* left, int* right, int* height, int* finalheight) {
for (int i = 0; i < k; i++) {
update(1, 0, n - 1, left[i], right[i], op[i], height[i]);
}
get(0, n - 1, 1);
for (int i = 0; i < n; i++) {
finalheight[i] = ans[i];
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
12 ms |
16344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
12 ms |
16416 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
11 ms |
16428 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
16 ms |
16352 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |