#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 << 20) + 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;
return;
}
lazy(tree_index);
get(l, (l + r) / 2, tree_index * 2);
get((l + r) / 2 + 1, r, tree_index * 2 + 1);
}
#include "wall.h"
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 |
Correct |
3 ms |
8148 KB |
Output is correct |
2 |
Correct |
5 ms |
8228 KB |
Output is correct |
3 |
Incorrect |
4 ms |
8068 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
8020 KB |
Output is correct |
2 |
Correct |
135 ms |
15912 KB |
Output is correct |
3 |
Incorrect |
77 ms |
12008 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8020 KB |
Output is correct |
2 |
Correct |
4 ms |
8148 KB |
Output is correct |
3 |
Incorrect |
5 ms |
8148 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8148 KB |
Output is correct |
2 |
Correct |
5 ms |
8148 KB |
Output is correct |
3 |
Incorrect |
4 ms |
8148 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |