# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
62629 |
2018-07-29T13:45:08 Z |
nvmdava |
Wall (IOI14_wall) |
C++17 |
|
8 ms |
892 KB |
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
#define SIZE 2097155
int maxTree[4 * SIZE], minTree[4 * SIZE], maxLazy[4 * SIZE], minLazy[4 * SIZE];
void down(int id){
if(maxLazy[id] == 0){
if(minLazy[id] == 0){
return;
}
maxTree[id] = min(minLazy[id], maxTree[id]);
minTree[id] = min(minTree[id], maxTree[id]);
minLazy[id << 1] = minLazy[id];
minLazy[id << 1 | 1] = minLazy[id];
minLazy[id] = 0;
} else {
minTree[id] = max(maxLazy[id], minTree[id]);
maxTree[id] = max(minTree[id], maxTree[id]);
maxLazy[id << 1] = maxLazy[id];
maxLazy[id << 1 | 1] = maxLazy[id];
maxLazy[id] = 0;
}
}
void downnn(int id){
if(maxLazy[id] == 0){
if(minLazy[id] == 0){
return;
}
maxTree[id] = min(minLazy[id], maxTree[id]);
minTree[id] = min(minTree[id], maxTree[id]);
} else {
minTree[id] = max(maxLazy[id], minTree[id]);
maxTree[id] = max(minTree[id], maxTree[id]);
}
}
void maximum(int id, int l, int r, int L, int R, int val){
down(id);
if(l == L && r == R){
maxLazy[id] = val;
return;
}
int m = (l + r) >> 1;
if(m >= R){
maximum(id << 1, l, m, L, R, val);
} else if( m < L){
maximum(id << 1 | 1, m + 1, r, L, R ,val);
} else {
maximum(id << 1, l, m, L, m, val);
maximum(id << 1 | 1, m + 1, r, m + 1, R ,val);
}
}
void minimum(int id, int l, int r, int L, int R, int val){
down(id);
if(l == L && r == R){
minLazy[id] = val;
return;
}
int m = (l + r) >> 1;
if(m >= R){
maximum(id << 1, l, m, L, R, val);
} else if( m < L){
maximum(id << 1 | 1, m + 1, r, L, R ,val);
} else {
maximum(id << 1, l, m, L, m, val);
maximum(id << 1 | 1, m + 1, r, m + 1, R ,val);
}
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
int i;
for(i = 0; i < k; i++){
if(op[i] == 1) maximum(1, 1, n, left[i], right[i], height[i]);
else minimum(1, 1, n, left[i], right[i], height[i]);
}
for(i = 1; i < 2097152; i++){
down(i);
}
n += 2097152;
for(i = 2097152 ; i < n; i++){
downnn(i);
finalHeight[i] = maxTree[i - 2097151];
}
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
556 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
752 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
892 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |