# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
931080 |
2024-02-21T07:57:30 Z |
Art_ogo |
Wall (IOI14_wall) |
C++17 |
|
597 ms |
90976 KB |
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <algorithm>
#include <utility>
#include "wall.h"
using namespace std;
const int MAXN = 3e6+10;
int t[4*MAXN];
int modmn[4*MAXN], modmx[4*MAXN];
void build(int v, int tl, int tr){
modmn[v] = 1e9;
modmx[v] = -1e9;
if(tl == tr){
t[v] = 0;
return;
}
int tm = (tl + tr) >> 1;
build(v * 2, tl, tm);
build(v * 2 + 1, tm + 1, tr);
}
void push(int v){
if(v * 2 + 1 > 4*MAXN) return;
if(modmn[v] != 1e9){
t[v * 2] = min(t[v * 2], modmn[v]);
modmn[v * 2] = min(modmn[v], modmn[v * 2]);
modmx[v * 2] = min(modmn[v], modmx[v * 2]);
t[v * 2 + 1] = min(t[v * 2 + 1], modmn[v]);
modmn[v * 2 + 1] = min(modmn[v], modmn[v * 2 + 1]);
modmx[v * 2 + 1] = min(modmn[v], modmx[v * 2 + 1]);
modmn[v] = 1e9;
}
if(modmx[v] != -1e9){
t[v * 2] = max(t[v * 2], modmx[v]);
modmn[v * 2] = max(modmx[v], modmn[v * 2]);
modmx[v * 2] = max(modmx[v], modmx[v * 2]);
t[v * 2 + 1] = max(t[v * 2 + 1], modmx[v]);
modmn[v * 2 + 1] = max(modmx[v], modmn[v * 2 + 1]);
modmx[v * 2 + 1] = max(modmx[v], modmx[v * 2 + 1]);
modmx[v] = -1e9;
}
}
void updmx(int l, int r, int val, int v, int tl, int tr){
if(tl >= l && tr <= r){
t[v] = max(t[v], val);
modmn[v] = max(modmn[v], val);
modmx[v] = max(modmx[v], val);
return;
}
if(tl > r || tr < l)
return;
push(v);
int tm = (tl + tr) >> 1;
updmx(l, r, val, v * 2, tl, tm);
updmx(l, r, val, v * 2 + 1, tm + 1, tr);
}
void updmn(int l, int r, int val, int v, int tl, int tr){
if(tl >= l && tr <= r){
t[v] = min(t[v], val);
modmn[v] = min(modmn[v], val);
modmx[v] = min(modmx[v], val);
return;
}
if(tl > r || tr < l)
return;
push(v);
int tm = (tl + tr) >> 1;
updmn(l, r, val, v * 2, tl, tm);
updmn(l, r, val, v * 2 + 1, tm + 1, tr);
}
int get(int idx, int v, int tl, int tr){
if(tl == tr)
return t[v];
push(v);
int tm = (tl + tr) >> 1;
if(idx <= tm)
return get(idx, v * 2, tl, tm);
else return get(idx, v * 2 + 1, tm + 1, tr);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
build(1, 0, n - 1);
for(int i = 0; i < k; i++)
if(op[i] == 1)
updmx(left[i], right[i], height[i], 1, 0, n - 1);
else updmn(left[i], right[i], height[i], 1, 0, n - 1);
for(int i = 0; i < n; i++)
finalHeight[i] = get(i, 1, 0, n - 1);
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
2 ms |
4444 KB |
Output is correct |
3 |
Correct |
2 ms |
4444 KB |
Output is correct |
4 |
Correct |
5 ms |
4696 KB |
Output is correct |
5 |
Correct |
4 ms |
4700 KB |
Output is correct |
6 |
Correct |
4 ms |
4700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
105 ms |
12120 KB |
Output is correct |
3 |
Correct |
118 ms |
8020 KB |
Output is correct |
4 |
Correct |
320 ms |
13960 KB |
Output is correct |
5 |
Correct |
202 ms |
14408 KB |
Output is correct |
6 |
Correct |
192 ms |
14404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4444 KB |
Output is correct |
2 |
Correct |
2 ms |
4444 KB |
Output is correct |
3 |
Correct |
2 ms |
4444 KB |
Output is correct |
4 |
Correct |
5 ms |
4696 KB |
Output is correct |
5 |
Correct |
7 ms |
4640 KB |
Output is correct |
6 |
Correct |
4 ms |
4700 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
102 ms |
12332 KB |
Output is correct |
9 |
Correct |
113 ms |
7908 KB |
Output is correct |
10 |
Correct |
319 ms |
13908 KB |
Output is correct |
11 |
Correct |
195 ms |
14424 KB |
Output is correct |
12 |
Correct |
190 ms |
14416 KB |
Output is correct |
13 |
Correct |
1 ms |
4440 KB |
Output is correct |
14 |
Correct |
100 ms |
12140 KB |
Output is correct |
15 |
Correct |
23 ms |
5208 KB |
Output is correct |
16 |
Correct |
374 ms |
14148 KB |
Output is correct |
17 |
Correct |
193 ms |
14160 KB |
Output is correct |
18 |
Correct |
221 ms |
14008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
2 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
6 ms |
4700 KB |
Output is correct |
5 |
Correct |
4 ms |
4696 KB |
Output is correct |
6 |
Correct |
4 ms |
4700 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
107 ms |
12364 KB |
Output is correct |
9 |
Correct |
113 ms |
8124 KB |
Output is correct |
10 |
Correct |
321 ms |
13836 KB |
Output is correct |
11 |
Correct |
195 ms |
14420 KB |
Output is correct |
12 |
Correct |
194 ms |
14672 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
100 ms |
12264 KB |
Output is correct |
15 |
Correct |
22 ms |
5208 KB |
Output is correct |
16 |
Correct |
369 ms |
14068 KB |
Output is correct |
17 |
Correct |
193 ms |
13980 KB |
Output is correct |
18 |
Correct |
193 ms |
14160 KB |
Output is correct |
19 |
Correct |
593 ms |
80380 KB |
Output is correct |
20 |
Correct |
592 ms |
88340 KB |
Output is correct |
21 |
Correct |
590 ms |
90708 KB |
Output is correct |
22 |
Correct |
594 ms |
88448 KB |
Output is correct |
23 |
Correct |
596 ms |
88148 KB |
Output is correct |
24 |
Correct |
587 ms |
88356 KB |
Output is correct |
25 |
Correct |
591 ms |
88148 KB |
Output is correct |
26 |
Correct |
595 ms |
90976 KB |
Output is correct |
27 |
Correct |
593 ms |
90704 KB |
Output is correct |
28 |
Correct |
597 ms |
88252 KB |
Output is correct |
29 |
Correct |
596 ms |
88144 KB |
Output is correct |
30 |
Correct |
592 ms |
88252 KB |
Output is correct |