Submission #232328

# Submission time Handle Problem Language Result Execution time Memory
232328 2020-05-16T18:53:36 Z islingr Wall (IOI14_wall) C++14
0 / 100
5 ms 384 KB
#include <iostream>
using namespace std;

const int inf = 1e9, N = 1 << 22;
int n; 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 = 1, int l = 0, int r = n) {
	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 = 1, int l = 0, int r = n) {
	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[]) {
	::n = n;
	// for (int i = 0; i < N; ++i) mn[i] = inf;
	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();
	}
	final(ans);
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -