# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
805369 |
2023-08-03T15:53:04 Z |
JoenPoenMan |
Wall (IOI14_wall) |
C++17 |
|
3000 ms |
13900 KB |
#include "wall.h"
#include <bits/stdc++.h>
#define ALL(arr) begin(arr), end(arr)
using namespace std;
struct Tree {
int v;
int x, y;
Tree *left = nullptr, *right = nullptr;
Tree(int v, int x, int y) : v(v), x(x), y(y) {}
};
void update(int a, int b, bool rem, int h, Tree *t, int lazy = -1) {
if (lazy != -1) t->v = lazy;
if (b < t->x || a > t->y) return;
if (a <= t->x && b >= t->y && !(t->left || t->right)) {
if (!rem) {
t->v = max(t->v, h);
} else {
t->v = min(t->v, h);
}
return;
}
if (!t->left) {
t->left = new Tree(0, t->x, (t->x + t->y)/2);
update(a, b, rem, h, t->left, t->v);
} else update(a, b, rem, h, t->left, -1);
if (!t->right) {
t->right = new Tree(0, (t->x + t->y)/2 + 1, t->y);
update(a, b, rem, h, t->right, t->v);
} else update(a, b, rem, h, t->right, -1);
}
void fillarr(int arr[], Tree *t) {
if (t->left) {
fillarr(arr, t->left);
fillarr(arr, t->right);
} else {
for (int i = t->x; i <= t->y; i++) {
arr[i] = t->v;
}
}
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
Tree *t = new Tree(0, 0, n-1);
for (int i = 0; i < k; i++) {
update(left[i], right[i], (op[i] == 1 ? false : true), height[i], t);
}
fillarr(finalHeight, t);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
115 ms |
1200 KB |
Output is correct |
5 |
Correct |
4 ms |
1236 KB |
Output is correct |
6 |
Correct |
4 ms |
1236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
111 ms |
13852 KB |
Output is correct |
3 |
Execution timed out |
3084 ms |
9184 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
304 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
117 ms |
1264 KB |
Output is correct |
5 |
Correct |
4 ms |
1204 KB |
Output is correct |
6 |
Correct |
4 ms |
1204 KB |
Output is correct |
7 |
Correct |
0 ms |
300 KB |
Output is correct |
8 |
Correct |
111 ms |
13900 KB |
Output is correct |
9 |
Execution timed out |
3057 ms |
9140 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
116 ms |
1220 KB |
Output is correct |
5 |
Correct |
4 ms |
1236 KB |
Output is correct |
6 |
Correct |
4 ms |
1268 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
113 ms |
13872 KB |
Output is correct |
9 |
Execution timed out |
3069 ms |
9136 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |