Submission #232338

# Submission time Handle Problem Language Result Execution time Memory
232338 2020-05-16T19:04:04 Z islingr Wall (IOI14_wall) C++14
100 / 100
701 ms 59384 KB
#include <iostream>
using namespace std;

const int inf = 1e9, N = 1 << 22;
int mx[N], mn[N];

void change(int v, int d, int u) {
	mn[v] = max(u, min(d, mn[v]));
	mx[v] = min(d, max(u, mx[v]));
}

void push(int v) {
	change(v << 1|0, mn[v], mx[v]);
	change(v << 1|1, mn[v], mx[v]);
	mx[v] = 0; mn[v] = inf;
}

int d, u, lo, hi;
void update(int v, int l, int r) {
	if (hi <= l || r <= lo) return;
	if (lo <= l && r <= hi) return change(v, d, u);
	push(v); int m = (l + r) / 2;
	update(v << 1|0, l, m);
	update(v << 1|1, m, r);
}

void final(int ans[], int v, int l, int r) {
	if (r - l == 1)
		return void(ans[l] = min(mx[v], mn[v]));
	push(v); int m = (l + r) / 2;
	final(ans, v << 1|0, l, m);
	final(ans, v << 1|1, m, r);
}

void buildWall(int n, int q, int op[], int l[], int r[], int h[], int ans[]) {
	for (int i = 0; i < N; ++i) mn[i] = inf, mx[i] = 0;
	for (int i = 0; i < q; ++i) {
		lo = l[i]; hi = r[i] + 1;
		if (op[i] != 1) d = h[i], u = 0;
		else d = inf, u = h[i];
		update(1, 0, n);
	}
	final(ans, 1, 0, n);
}
# Verdict Execution time Memory Grader output
1 Correct 23 ms 33152 KB Output is correct
2 Correct 25 ms 33280 KB Output is correct
3 Correct 31 ms 33280 KB Output is correct
4 Correct 28 ms 33444 KB Output is correct
5 Correct 26 ms 33408 KB Output is correct
6 Correct 27 ms 33400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 33152 KB Output is correct
2 Correct 199 ms 42488 KB Output is correct
3 Correct 197 ms 38392 KB Output is correct
4 Correct 482 ms 43256 KB Output is correct
5 Correct 327 ms 43564 KB Output is correct
6 Correct 324 ms 43768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 33152 KB Output is correct
2 Correct 23 ms 33280 KB Output is correct
3 Correct 23 ms 33152 KB Output is correct
4 Correct 28 ms 33536 KB Output is correct
5 Correct 26 ms 33400 KB Output is correct
6 Correct 26 ms 33400 KB Output is correct
7 Correct 21 ms 33152 KB Output is correct
8 Correct 198 ms 40952 KB Output is correct
9 Correct 192 ms 36576 KB Output is correct
10 Correct 489 ms 41592 KB Output is correct
11 Correct 344 ms 42088 KB Output is correct
12 Correct 325 ms 42104 KB Output is correct
13 Correct 22 ms 33152 KB Output is correct
14 Correct 197 ms 41056 KB Output is correct
15 Correct 51 ms 33784 KB Output is correct
16 Correct 489 ms 41840 KB Output is correct
17 Correct 330 ms 41848 KB Output is correct
18 Correct 334 ms 41848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 33152 KB Output is correct
2 Correct 23 ms 33280 KB Output is correct
3 Correct 23 ms 33152 KB Output is correct
4 Correct 27 ms 33280 KB Output is correct
5 Correct 27 ms 33400 KB Output is correct
6 Correct 26 ms 33280 KB Output is correct
7 Correct 22 ms 33144 KB Output is correct
8 Correct 194 ms 41056 KB Output is correct
9 Correct 193 ms 36472 KB Output is correct
10 Correct 498 ms 41592 KB Output is correct
11 Correct 327 ms 42136 KB Output is correct
12 Correct 320 ms 42232 KB Output is correct
13 Correct 22 ms 33152 KB Output is correct
14 Correct 198 ms 41080 KB Output is correct
15 Correct 49 ms 33784 KB Output is correct
16 Correct 489 ms 41848 KB Output is correct
17 Correct 335 ms 41848 KB Output is correct
18 Correct 324 ms 41804 KB Output is correct
19 Correct 680 ms 59384 KB Output is correct
20 Correct 701 ms 56708 KB Output is correct
21 Correct 675 ms 59128 KB Output is correct
22 Correct 674 ms 56568 KB Output is correct
23 Correct 683 ms 56696 KB Output is correct
24 Correct 670 ms 56568 KB Output is correct
25 Correct 674 ms 56568 KB Output is correct
26 Correct 697 ms 59196 KB Output is correct
27 Correct 692 ms 59128 KB Output is correct
28 Correct 691 ms 56572 KB Output is correct
29 Correct 678 ms 56696 KB Output is correct
30 Correct 677 ms 56696 KB Output is correct