# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
122827 |
2019-06-29T10:45:14 Z |
turbat |
Wall (IOI14_wall) |
C++14 |
|
544 ms |
12336 KB |
#include <bits/stdc++.h>
#include "wall.h"
using namespace std;
#define N 500005
int lim[4 * N], seg[4 * N], h[N];
void clear(int nd){
lim[nd * 2] = min(lim[nd * 2], lim[nd]);
lim[nd * 2 + 1] = min(lim[nd * 2 + 1], lim[nd]);
seg[nd * 2] = max(seg[nd * 2], min(lim[nd * 2], seg[nd]));
seg[nd * 2 + 1] = max(seg[nd * 2 + 1], min(lim[nd * 2 + 1], seg[nd]));
}
void update(int nd, int L, int R, int l, int r, int h, int t){
// cout << nd << ' '<< L << ' ' << R<< endl;
if (r < L || R < l) return;
if (t == 1) h = min(h, lim[nd]);
if (l <= L && R <= r){
if (t == 1) seg[nd] = max(seg[nd], h);
else lim[nd] = min(h, lim[nd]);
return;
}
clear(nd);
update(nd * 2, L, (L + R) / 2, l, r, h, t);
update(nd * 2 + 1, (L + R) / 2 + 1, R, l, r, h, t);
}
void end(int nd, int l, int r){
if (l == r){
h[l] = seg[nd];
return;
}
clear(nd);
end(nd * 2, l, (l + r) / 2);
end(nd * 2 + 1, (l + r) / 2 + 1, r);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
for (int i = 0;i <= 4 * n;i++) lim[i] = 2e9;
for (int i = k - 1;i >= 0;i--) update(1, 0, n - 1, left[i], right[i], height[i], op[i]);
end(1, 0, n - 1);
for (int i = 0;i < n;i++) finalHeight[i] = h[i];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
169 ms |
8192 KB |
Output is correct |
3 |
Correct |
195 ms |
4292 KB |
Output is correct |
4 |
Correct |
544 ms |
11808 KB |
Output is correct |
5 |
Correct |
338 ms |
12220 KB |
Output is correct |
6 |
Correct |
324 ms |
12336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |