# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
1113646 |
2024-11-16T22:56:45 Z |
sunboi |
벽 (IOI14_wall) |
C++17 |
|
261 ms |
85076 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
vector<int> a(N);
vector<pair<long long, long long>> t(4 * N);
vector<pair<long long, long long>> lazy(8 * N, {0, -1});
void push(int v, int vl, int vr){
if (lazy[v].second == -1) return;
if (lazy[v].second == 1){
long long x = lazy[v].first;
t[v * 2] = {min(t[v * 2].first, x), min(t[v * 2].second, x)};
t[v * 2 + 1] = {min(t[v * 2 + 1].first, x), min(t[v * 2 + 1].second, x)};
push(2 * v, vl, (vl + vr) / 2);
push(2 * v + 1, (vl + vr) / 2 + 1, vr);
if (lazy[v * 2].second == 0 || lazy[v * 2 + 1].second == -1) lazy[v * 2] = {x, 1};
else lazy[v * 2] = {min(lazy[v * 2].first, x), 1};
if (lazy[v * 2 + 1].second == 0 || lazy[v * 2 + 1].second == -1) lazy[v * 2 + 1] = {x, 1};
else lazy[v * 2 + 1] = {min(lazy[v * 2 + 1].first, x), 1};
lazy[v] = {0, -1};
}else if (lazy[v].second == 0){
long long x = lazy[v].first;
t[v * 2] = {max(t[v * 2].first, x), max(t[v * 2].second, x)};
t[v * 2 + 1] = {max(t[v * 2 + 1].first, x), max(t[v * 2 + 1].second, x)};
if (lazy[v * 2].second == 1 || lazy[v * 2 + 1].second == -1) lazy[v * 2] = {x, 0};
else lazy[v * 2] = {max(lazy[v * 2].first, x), 0};
if (lazy[v * 2 + 1].second == 1 || lazy[v * 2 + 1].second == -1) lazy[v * 2 + 1] = {x, 0};
else lazy[v * 2 + 1] = {max(lazy[v * 2 + 1].first, x), 0};
lazy[v] = {0, -1};
}
}
void build(int v, int vl, int vr) {
if (vl == vr) {
t[v] = {0, 0};
return;
}
int vm = (vl + vr) / 2;
build(2 * v, vl, vm);
build(2 * v + 1, vm + 1, vr);
t[v] = {max(t[2 * v].first, t[2 * v + 1].first), min(t[2 * v].second, t[2 * v + 1].second)};
}
void update(int v, int vl, int vr, int l, int r, long long x){
if (vl > r || vr < l) return;
if (vl != vr) push(v, vl ,vr);
if (vl >= l && vr <= r){
t[v] = {max(t[v].first, x), max(t[v].second, x)};
if (lazy[v].second == 1 || lazy[v].second == -1) lazy[v] = {x, 0};
else lazy[v] = {max(lazy[v].first, x), 0};
return;
}
int vm = (vl + vr) / 2;
update(2 * v, vl, vm, l, r, x);
update(2 * v + 1, vm + 1, vr, l, r, x);
t[v] = {max(t[2 * v].first, t[2 * v + 1].first), min(t[2 * v].second, t[2 * v + 1].second)};
}
void update2(int v, int vl, int vr, int l, int r, long long x){
if (vl > r || vr < l) return;
if (vl != vr) push(v, vl ,vr);
if (vl >= l && vr <= r){
t[v] = {min(t[v].first, x), min(t[v].second, x)};
if (lazy[v].second == 0 || lazy[v].second == -1) lazy[v] = {x, 1};
else lazy[v] = {min(lazy[v].first, x), 1};
return;
}
int vm = (vl + vr) / 2;
update2(2 * v, vl, vm, l, r, x);
update2(2 * v + 1, vm + 1, vr, l, r, x);
t[v] = {max(t[2 * v].first, t[2 * v + 1].first), min(t[2 * v].second, t[2 * v + 1].second)};
}
int get(int v, int vl, int vr, int x){
if (vl > x || vr < x) return 0;
if (vr <= x && x <= vl){
return t[v].first;
}
push(v, vl, vr);
int vm = (vl + vr) / 2;
return max(get(2 * v, vl, vm, x), get(2 * v + 1, vm + 1, vr, x));
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
for (int i = 0; i < n; i++){
a[i] = 0;
}
build(1, 0, n - 1);
for (int i = 0; i < k; i++){
if (op[i] == 1){
update(1, 0, n - 1, left[i], right[i], height[i]);
}else update2(1, 0, n - 1, left[i], right[i], height[i]);
/*for (int j = 0; j < n; j++){
finalHeight[j] = get(1, 0, n - 1, j);
}
for (int j = 0; j < n; j++) {
cout << finalHeight[j] << endl;
}
cout << endl;*/
}
for (int i = 0; i < n; i++){
finalHeight[i] = get(1, 0, n - 1, i);
}
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
38736 KB |
Output is correct |
2 |
Correct |
7 ms |
38736 KB |
Output is correct |
3 |
Runtime error |
58 ms |
78224 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
38748 KB |
Output is correct |
2 |
Correct |
98 ms |
46420 KB |
Output is correct |
3 |
Runtime error |
261 ms |
85076 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
38736 KB |
Output is correct |
2 |
Correct |
8 ms |
38868 KB |
Output is correct |
3 |
Runtime error |
64 ms |
78408 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
38736 KB |
Output is correct |
2 |
Correct |
6 ms |
38736 KB |
Output is correct |
3 |
Runtime error |
61 ms |
78324 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |