# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
939737 |
2024-03-06T17:20:14 Z |
asdasdqwer |
Wall (IOI14_wall) |
C++14 |
|
718 ms |
69512 KB |
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
int le;
vector<int> lzMin, lzMax;
const int minConst = 1e9;
const int maxConst = 0;
void init (int sz) {
le=1;
while(le<sz)le*=2;
lzMin.assign(2*le, minConst);
lzMax.assign(2*le, maxConst);
}
void pushdown(int x) {
if (lzMin[x] == minConst && lzMax[x] == maxConst) {
return;
}
lzMin[2*x+1] = min(max(lzMax[x], lzMin[2*x+1]), lzMin[x]);
lzMin[2*x+2] = min(max(lzMax[x], lzMin[2*x+2]), lzMin[x]);
lzMax[2*x+1] = max(min(lzMin[x], lzMax[2*x+1]), lzMax[x]);
lzMax[2*x+2] = max(min(lzMin[x], lzMax[2*x+2]), lzMax[x]);
lzMin[x] = minConst;
lzMax[x] = maxConst;
}
void setVal(int l, int r, int v, int x, int lx, int rx, bool isMax=false) {
if (lx >= r || rx <= l) return;
if (rx - lx == 1) {
if (isMax) {
if (lzMax[x] < v) {
lzMax[x] = v;
}
if (lzMin[x] < v) {
lzMin[x] = v;
}
}
else {
if (lzMin[x] > v) {
lzMin[x] = v;
}
if (lzMax[x] > v) {
lzMax[x] = v;
}
}
return;
}
pushdown(x);
if (lx >= l && rx <= r) {
if (isMax) {
if (lzMax[x] < v) {
lzMax[x] = v;
}
if (lzMin[x] < v) {
lzMin[x] = v;
}
}
else {
if (lzMin[x] > v) {
lzMin[x] = v;
}
if (lzMax[x] > v) {
lzMax[x] = v;
}
}
return;
}
int m=(lx+rx)/2;
setVal(l, r, v, 2*x+1, lx, m, isMax);
setVal(l, r, v, 2*x+2, m, rx, isMax);
}
void setMax(int l, int r, int v) {
setVal(l, r, v, 0, 0, le, true);
}
void setMin(int l, int r, int v) {
setVal(l, r, v, 0, 0, le, false);
}
int get(int i, int x, int lx, int rx) {
if (rx-lx==1) {
return lzMax[x];
}
pushdown(x);
int m=(lx+rx)/2;
if (i<m)return get(i,2*x+1,lx,m);
else return get(i,2*x+2,m,rx);
}
int get(int i) {
return get(i,0,0,le);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) {
init(n);
for (int i=0;i<k;i++) {
if (op[i] == 1) {
setMax(left[i], right[i]+1, height[i]);
}
else {
setMin(left[i], right[i]+1, height[i]);
}
}
for (int i=0;i<n;i++) {
finalHeight[i] = get(i);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
412 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
5 ms |
860 KB |
Output is correct |
5 |
Correct |
6 ms |
908 KB |
Output is correct |
6 |
Correct |
6 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
104 ms |
11216 KB |
Output is correct |
3 |
Correct |
173 ms |
5656 KB |
Output is correct |
4 |
Correct |
440 ms |
20440 KB |
Output is correct |
5 |
Correct |
200 ms |
21412 KB |
Output is correct |
6 |
Correct |
201 ms |
19780 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
556 KB |
Output is correct |
3 |
Correct |
1 ms |
476 KB |
Output is correct |
4 |
Correct |
5 ms |
888 KB |
Output is correct |
5 |
Correct |
4 ms |
856 KB |
Output is correct |
6 |
Correct |
4 ms |
860 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
113 ms |
11092 KB |
Output is correct |
9 |
Correct |
207 ms |
6304 KB |
Output is correct |
10 |
Correct |
413 ms |
20336 KB |
Output is correct |
11 |
Correct |
199 ms |
21332 KB |
Output is correct |
12 |
Correct |
209 ms |
19824 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
108 ms |
14004 KB |
Output is correct |
15 |
Correct |
24 ms |
2136 KB |
Output is correct |
16 |
Correct |
467 ms |
20804 KB |
Output is correct |
17 |
Correct |
201 ms |
20052 KB |
Output is correct |
18 |
Correct |
219 ms |
20120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
5 ms |
908 KB |
Output is correct |
5 |
Correct |
4 ms |
860 KB |
Output is correct |
6 |
Correct |
4 ms |
904 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
118 ms |
11228 KB |
Output is correct |
9 |
Correct |
142 ms |
6276 KB |
Output is correct |
10 |
Correct |
408 ms |
20444 KB |
Output is correct |
11 |
Correct |
198 ms |
21588 KB |
Output is correct |
12 |
Correct |
202 ms |
19860 KB |
Output is correct |
13 |
Correct |
0 ms |
600 KB |
Output is correct |
14 |
Correct |
122 ms |
14028 KB |
Output is correct |
15 |
Correct |
24 ms |
2140 KB |
Output is correct |
16 |
Correct |
415 ms |
20692 KB |
Output is correct |
17 |
Correct |
217 ms |
20164 KB |
Output is correct |
18 |
Correct |
223 ms |
20132 KB |
Output is correct |
19 |
Correct |
656 ms |
69456 KB |
Output is correct |
20 |
Correct |
673 ms |
67340 KB |
Output is correct |
21 |
Correct |
671 ms |
69512 KB |
Output is correct |
22 |
Correct |
669 ms |
67384 KB |
Output is correct |
23 |
Correct |
718 ms |
67116 KB |
Output is correct |
24 |
Correct |
668 ms |
67152 KB |
Output is correct |
25 |
Correct |
661 ms |
67068 KB |
Output is correct |
26 |
Correct |
662 ms |
69460 KB |
Output is correct |
27 |
Correct |
671 ms |
69476 KB |
Output is correct |
28 |
Correct |
674 ms |
66920 KB |
Output is correct |
29 |
Correct |
649 ms |
66964 KB |
Output is correct |
30 |
Correct |
653 ms |
67000 KB |
Output is correct |