# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
540250 |
2022-03-19T18:11:12 Z |
dxz05 |
Wall (IOI14_wall) |
C++14 |
|
1179 ms |
88992 KB |
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
struct node{
int mn;
int mx;
node(){
mn = 1e9;
mx = -1e9;
}
};
const int N = 2e6 + 3e2;
node t[4 * N];
void chmin(node &var, int val){
var.mn = min(var.mn, val);
var.mx = min(var.mx, val);
}
void chmax(node &var, int val){
var.mn = max(var.mn, val);
var.mx = max(var.mx, val);
}
void push(int v){
if (t[v].mn != 1e9){
chmin(t[v + v], t[v].mn);
chmin(t[v + v + 1], t[v].mn);
t[v].mn = 1e9;
}
if (t[v].mx != -1e9){
chmax(t[v + v], t[v].mx);
chmax(t[v + v + 1], t[v].mx);
t[v].mx = -1e9;
}
}
void update(int v, int tl, int tr, int l, int r, int val, char type){
if (l <= tl && tr <= r){
if (type == '+'){
chmax(t[v], val);
} else {
chmin(t[v], val);
}
return;
}
if (tl > r || tr < l) return;
push(v);
int tm = (tl + tr) >> 1;
update(v + v, tl, tm, l, r, val, type);
update(v + v + 1, tm + 1, tr, l, r, val, type);
}
node get(int v, int tl, int tr, int pos){
if (tl == tr) return t[v];
push(v);
int tm = (tl + tr) >> 1;
if (pos <= tm) return get(v + v, tl, tm, pos); else
return get(v + v + 1, tm + 1, tr, pos);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
for (int i = 0; i < n; i++){
update(1, 0, n - 1, i, i, 0, '+');
}
for (int i = 0; i < k; i++){
update(1, 0, n - 1, left[i], right[i], height[i], op[i] == 1 ? '+' : '-');
}
for (int i = 0; i < n; i++){
finalHeight[i] = get(1, 0, n - 1, i).mx;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
62932 KB |
Output is correct |
2 |
Correct |
28 ms |
62932 KB |
Output is correct |
3 |
Correct |
28 ms |
62868 KB |
Output is correct |
4 |
Correct |
35 ms |
62996 KB |
Output is correct |
5 |
Correct |
33 ms |
63060 KB |
Output is correct |
6 |
Correct |
40 ms |
63052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
62932 KB |
Output is correct |
2 |
Correct |
159 ms |
70736 KB |
Output is correct |
3 |
Correct |
192 ms |
66416 KB |
Output is correct |
4 |
Correct |
423 ms |
71384 KB |
Output is correct |
5 |
Correct |
293 ms |
71884 KB |
Output is correct |
6 |
Correct |
277 ms |
71808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
62872 KB |
Output is correct |
2 |
Correct |
30 ms |
62972 KB |
Output is correct |
3 |
Correct |
29 ms |
62932 KB |
Output is correct |
4 |
Correct |
35 ms |
63016 KB |
Output is correct |
5 |
Correct |
35 ms |
62980 KB |
Output is correct |
6 |
Correct |
34 ms |
63076 KB |
Output is correct |
7 |
Correct |
28 ms |
62932 KB |
Output is correct |
8 |
Correct |
155 ms |
70684 KB |
Output is correct |
9 |
Correct |
191 ms |
66244 KB |
Output is correct |
10 |
Correct |
432 ms |
71244 KB |
Output is correct |
11 |
Correct |
288 ms |
71788 KB |
Output is correct |
12 |
Correct |
279 ms |
71840 KB |
Output is correct |
13 |
Correct |
28 ms |
62872 KB |
Output is correct |
14 |
Correct |
155 ms |
70716 KB |
Output is correct |
15 |
Correct |
61 ms |
63544 KB |
Output is correct |
16 |
Correct |
560 ms |
71540 KB |
Output is correct |
17 |
Correct |
301 ms |
71532 KB |
Output is correct |
18 |
Correct |
285 ms |
71664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
62796 KB |
Output is correct |
2 |
Correct |
31 ms |
62932 KB |
Output is correct |
3 |
Correct |
29 ms |
62864 KB |
Output is correct |
4 |
Correct |
35 ms |
63056 KB |
Output is correct |
5 |
Correct |
34 ms |
63004 KB |
Output is correct |
6 |
Correct |
34 ms |
63004 KB |
Output is correct |
7 |
Correct |
28 ms |
62900 KB |
Output is correct |
8 |
Correct |
154 ms |
70728 KB |
Output is correct |
9 |
Correct |
190 ms |
66296 KB |
Output is correct |
10 |
Correct |
429 ms |
71448 KB |
Output is correct |
11 |
Correct |
289 ms |
71792 KB |
Output is correct |
12 |
Correct |
290 ms |
71872 KB |
Output is correct |
13 |
Correct |
30 ms |
62844 KB |
Output is correct |
14 |
Correct |
158 ms |
70700 KB |
Output is correct |
15 |
Correct |
59 ms |
63492 KB |
Output is correct |
16 |
Correct |
517 ms |
71600 KB |
Output is correct |
17 |
Correct |
289 ms |
71500 KB |
Output is correct |
18 |
Correct |
288 ms |
71544 KB |
Output is correct |
19 |
Correct |
1179 ms |
88992 KB |
Output is correct |
20 |
Correct |
1162 ms |
86452 KB |
Output is correct |
21 |
Correct |
1157 ms |
88904 KB |
Output is correct |
22 |
Correct |
1164 ms |
86516 KB |
Output is correct |
23 |
Correct |
1156 ms |
86360 KB |
Output is correct |
24 |
Correct |
1155 ms |
86412 KB |
Output is correct |
25 |
Correct |
1176 ms |
86336 KB |
Output is correct |
26 |
Correct |
1177 ms |
88816 KB |
Output is correct |
27 |
Correct |
1161 ms |
88816 KB |
Output is correct |
28 |
Correct |
1165 ms |
86424 KB |
Output is correct |
29 |
Correct |
1174 ms |
86368 KB |
Output is correct |
30 |
Correct |
1157 ms |
86412 KB |
Output is correct |