# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
298684 |
2020-09-13T19:42:05 Z |
aymanrs |
Wall (IOI14_wall) |
C++14 |
|
3000 ms |
14076 KB |
#include <bits/stdc++.h>
#define L(i) i*2+1
#define R(i) i*2+2
using namespace std;
typedef pair<int, int> pii;
pii update(int i, int l, int r, int a, int b, pii op, pii tree[], pii lazy[]){
if(lazy[i].first != -1){
tree[i].first = min(max(tree[i].first, lazy[i].first), lazy[i].second);
tree[i].second = max(min(tree[i].second, lazy[i].second), lazy[i].first);
if(l != r) {
lazy[L(i)] = lazy[R(i)] = {tree[i].first, tree[i].second};
}
lazy[i] = {-1, -1};
}
if(l > b || r < a) return tree[i];
if(a <= l && r <= b){
if(op.first == 1){
tree[i].first = max(tree[i].first, op.second);
if(tree[i].first > tree[i].second){
tree[i].second = tree[i].first;
}
} else {
tree[i].second = min(tree[i].second, op.second);
if(tree[i].first > tree[i].second){
tree[i].first = tree[i].second;
}
}
if(l != r) lazy[L(i)] = lazy[R(i)] = tree[i];
}
if(l != r){
int mid = (l+r)/2;
pii left = update(L(i), l, mid, a, b, op, tree, lazy), right = update(R(i), mid+1, r, a, b, op, tree, lazy);
tree[i] = {min(left.first, right.first), max(left.second, right.second)};
}
return tree[i];
}
int get(int i, int l, int r, int ind, pii tree[], pii lazy[]){
if(lazy[i].first != -1){
tree[i].first = min(max(tree[i].first, lazy[i].first), lazy[i].second);
tree[i].second = max(min(tree[i].second, lazy[i].second), lazy[i].first);
if(l != r) {
lazy[L(i)] = lazy[R(i)] = {tree[i].first, tree[i].second};
}
lazy[i] = {-1, -1};
}
if(l > ind || r < ind) return -1;
if(l == r)
return tree[i].first;
int mid = (l+r)/2;
return max(get(L(i), l, mid, ind, tree, lazy), get(R(i), mid+1, r, ind, tree, lazy));
}
void buildWall(int n, int k, int op[], int left[], int right[],int height[], int finalHeight[]){
pii tree[4 * n + 10], lazy[4 * n + 10];
for(int i = 0;i < 4*n+10;i++) {
lazy[i] = {-1, -1};
tree[i] = {0, 0};
}
for(int i = 0;i < k;i++){
update(0, 0, n-1, left[i], right[i], {op[i], height[i]}, tree, lazy);
}
for(int i = 0;i < n;i++){
finalHeight[i] = get(0, 0, n-1, i, tree, lazy);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
9 ms |
384 KB |
Output is correct |
4 |
Correct |
684 ms |
1304 KB |
Output is correct |
5 |
Correct |
697 ms |
1152 KB |
Output is correct |
6 |
Correct |
698 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
191 ms |
13688 KB |
Output is correct |
3 |
Execution timed out |
3052 ms |
8568 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
9 ms |
384 KB |
Output is correct |
4 |
Correct |
686 ms |
1272 KB |
Output is correct |
5 |
Correct |
687 ms |
1272 KB |
Output is correct |
6 |
Correct |
698 ms |
1272 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
198 ms |
14076 KB |
Output is correct |
9 |
Execution timed out |
3046 ms |
8568 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
9 ms |
384 KB |
Output is correct |
4 |
Correct |
683 ms |
1272 KB |
Output is correct |
5 |
Correct |
687 ms |
1272 KB |
Output is correct |
6 |
Correct |
695 ms |
1272 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
192 ms |
13944 KB |
Output is correct |
9 |
Execution timed out |
3040 ms |
8568 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |