# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
805404 |
2023-08-03T16:24:36 Z |
HaroldVemeno |
Wall (IOI14_wall) |
C++17 |
|
511 ms |
69516 KB |
#include "wall.h"
#include <bits/stdc++.h>
#ifdef GUDEB
#define D(x) cerr << #x << ": " << (x) << '\n';
#define ifdeb if(true)
#else
#define D(x) ;
#define ifdeb if(false)
#endif
#define all(x) begin(x), end(x)
using namespace std;
using ull = unsigned long long;
using ll = long long;
// #define int ll;
int n;
int s;
int lbs[8000000];
int ubs[8000000];
void push(int x) {
if(x >= s) return;
for(int c : {2*x, 2*x+1}) {
lbs[c] = max(lbs[c], lbs[x]);
lbs[c] = min(lbs[c], ubs[x]);
ubs[c] = min(ubs[c], ubs[x]);
ubs[c] = max(ubs[c], lbs[x]);
}
ubs[x] = 100000;
lbs[x] = 0;
}
void walk(int l, int r, int op, int h, int u, int lu, int ru) {
D(l)
D(r)
D(u)
D(lu)
D(ru)
if(r <= lu || ru <= l) return;
if(l <= lu && ru <= r) {
if(op == 1) {
lbs[u] = max(lbs[u], h);
ubs[u] = max(ubs[u], lbs[u]);
} else {
ubs[u] = min(ubs[u], h);
lbs[u] = min(lbs[u], ubs[u]);
}
return;
}
push(u);
int mu = (lu+ru)/2;
walk(l, r, op, h, 2*u , lu, mu);
walk(l, r, op, h, 2*u+1, mu, ru);
}
void buildWall(int N, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
n = N;
s = 1;
while(s < n) s *= 2;
for(int i = s-1; i > 0; --i) {
ubs[i] = 100000;
}
for(int i = 0; i < k; ++i) {
walk(left[i], right[i]+1, op[i], height[i], 1, 0, s);
}
for(int i = 1; i < s; ++i) {
push(i);
}
for(int i = 0; i < n; ++i) {
finalHeight[i] = lbs[s+i];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
308 KB |
Output is correct |
2 |
Correct |
2 ms |
448 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Correct |
4 ms |
724 KB |
Output is correct |
5 |
Correct |
4 ms |
724 KB |
Output is correct |
6 |
Correct |
4 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
104 ms |
8324 KB |
Output is correct |
3 |
Correct |
135 ms |
4376 KB |
Output is correct |
4 |
Correct |
344 ms |
20376 KB |
Output is correct |
5 |
Correct |
212 ms |
21432 KB |
Output is correct |
6 |
Correct |
212 ms |
19820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
448 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
4 ms |
724 KB |
Output is correct |
5 |
Correct |
6 ms |
764 KB |
Output is correct |
6 |
Correct |
4 ms |
724 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
104 ms |
8372 KB |
Output is correct |
9 |
Correct |
133 ms |
4432 KB |
Output is correct |
10 |
Correct |
360 ms |
20368 KB |
Output is correct |
11 |
Correct |
212 ms |
21396 KB |
Output is correct |
12 |
Correct |
207 ms |
19828 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
107 ms |
13956 KB |
Output is correct |
15 |
Correct |
21 ms |
1892 KB |
Output is correct |
16 |
Correct |
347 ms |
20620 KB |
Output is correct |
17 |
Correct |
207 ms |
20052 KB |
Output is correct |
18 |
Correct |
208 ms |
20048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
444 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
4 ms |
724 KB |
Output is correct |
5 |
Correct |
4 ms |
832 KB |
Output is correct |
6 |
Correct |
4 ms |
724 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
102 ms |
8372 KB |
Output is correct |
9 |
Correct |
120 ms |
4428 KB |
Output is correct |
10 |
Correct |
343 ms |
20388 KB |
Output is correct |
11 |
Correct |
227 ms |
21388 KB |
Output is correct |
12 |
Correct |
216 ms |
19800 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
104 ms |
13924 KB |
Output is correct |
15 |
Correct |
20 ms |
1984 KB |
Output is correct |
16 |
Correct |
348 ms |
20628 KB |
Output is correct |
17 |
Correct |
217 ms |
20140 KB |
Output is correct |
18 |
Correct |
212 ms |
19952 KB |
Output is correct |
19 |
Correct |
484 ms |
69468 KB |
Output is correct |
20 |
Correct |
478 ms |
67020 KB |
Output is correct |
21 |
Correct |
502 ms |
69516 KB |
Output is correct |
22 |
Correct |
491 ms |
67000 KB |
Output is correct |
23 |
Correct |
480 ms |
67056 KB |
Output is correct |
24 |
Correct |
511 ms |
66956 KB |
Output is correct |
25 |
Correct |
509 ms |
66908 KB |
Output is correct |
26 |
Correct |
511 ms |
69516 KB |
Output is correct |
27 |
Correct |
495 ms |
69492 KB |
Output is correct |
28 |
Correct |
481 ms |
66960 KB |
Output is correct |
29 |
Correct |
496 ms |
67152 KB |
Output is correct |
30 |
Correct |
477 ms |
67052 KB |
Output is correct |