# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
997776 |
2024-06-12T20:10:36 Z |
coolboy19521 |
Wall (IOI14_wall) |
C++17 |
|
554 ms |
243536 KB |
#include "bits/stdc++.h"
#include "wall.h"
using namespace std;
const int sz = 5e6;
struct que {
int ad, rm;
que() : ad(INT_MIN), rm(INT_MAX) {}
que(int le, int ri) : ad(le), rm(ri) {}
};
int st[sz * 4];
que lz[sz * 4];
void merge(que& le, que& ri) {
if (ri.rm == INT_MAX) {
le.ad = max(le.ad, ri.ad);
} else {
le.rm = min(le.rm, ri.rm);
le.ad = min(le.ad, le.rm);
}
}
void relax(int v, int le, int ri) {
if (lz[v].ad != INT_MIN || lz[v].rm != INT_MAX) {
if (lz[v].ad != INT_MIN) {
st[v] = max(st[v], lz[v].ad);
}
if (lz[v].rm != INT_MAX) {
st[v] = min(st[v], lz[v].rm);
}
if (le != ri) {
merge(lz[v * 2], lz[v]);
merge(lz[v * 2 + 1], lz[v]);
}
lz[v] = que();
}
}
void update(int le, int ri, int ql, int qr, int v, que q) {
relax(v, le, ri);
if (le > qr || ri < ql) return;
if (ql <= le && ri <= qr) {
merge(lz[v], q);
relax(v, le, ri);
} else {
int mi = le + (ri - le) / 2;
update(le, mi, ql, qr, v * 2, q);
update(mi + 1, ri, ql, qr, v * 2 + 1, q);
st[v] = min(st[v * 2], st[v * 2 + 1]);
}
}
int query(int le, int ri, int ix, int v) {
relax(v, le, ri);
if (le > ix || ri < ix) return INT_MAX;
if (le == ri) return st[v];
int mi = le + (ri - le) / 2;
if (ix <= mi) return query(le, mi, ix, v * 2);
return query(mi + 1, ri, ix, v * 2 + 1);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) {
fill(st, st + sz * 4, 0);
fill(lz, lz + sz * 4, que());
for (int i = 0; i < k; i++) {
if (1 == op[i]) {
que q = {height[i], INT_MAX};
update(1, n, left[i] + 1, right[i] + 1, 1, q);
} else {
que q = {INT_MIN, height[i]};
update(1, n, left[i] + 1, right[i] + 1, 1, q);
}
}
for (int i = 0; i < n; i++) {
finalHeight[i] = query(1, n, i + 1, 1);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
106 ms |
235000 KB |
Output is correct |
2 |
Correct |
84 ms |
235128 KB |
Output is correct |
3 |
Incorrect |
87 ms |
235128 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
82 ms |
235092 KB |
Output is correct |
2 |
Correct |
164 ms |
243000 KB |
Output is correct |
3 |
Correct |
222 ms |
238564 KB |
Output is correct |
4 |
Incorrect |
554 ms |
243536 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
84 ms |
235204 KB |
Output is correct |
2 |
Correct |
91 ms |
235304 KB |
Output is correct |
3 |
Incorrect |
85 ms |
235180 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
85 ms |
235144 KB |
Output is correct |
2 |
Correct |
83 ms |
235220 KB |
Output is correct |
3 |
Incorrect |
84 ms |
235032 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |