답안 #1087422

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1087422 2024-09-12T16:30:09 Z eysbutno 벽 (IOI14_wall) C++17
100 / 100
769 ms 89144 KB
#include <bits/stdc++.h>
using namespace std;

struct Update {
	int min_val = 0;
	int max_val = INT_MAX;
};
class Segtree {
	const int sz;
	vector<Update> t;

	void apply(int v, const Update &x) {
		t[v].min_val = max(t[v].min_val, x.min_val);
		t[v].max_val = max(t[v].max_val, t[v].min_val);
		t[v].max_val = min(t[v].max_val, x.max_val);
		t[v].min_val = min(t[v].min_val, t[v].max_val);
	}

	void pushdown(int v) {
		apply(2 * v, t[v]);
		apply(2 * v + 1, t[v]);
		t[v] = Update();
	}

	void update(int v, int l, int r, int ql, int qr, const Update &x) {
		if (qr < l || ql > r) { return; }
		if (ql <= l && r <= qr) {
			apply(v, x);
		} else {
			pushdown(v);
			int m = (l + r) / 2;
			update(2 * v, l, m, ql, qr, x);
			update(2 * v + 1, m + 1, r, ql, qr, x);
		}
	}

	Update query(int v, int l, int r, int idx) {
		if (l == r) {
			return t[v];
		} else {
			pushdown(v);
			int m = (l + r) / 2;
			return (idx <= m) ? query(2 * v, l, m, idx)
			                  : query(2 * v + 1, m + 1, r, idx);
		}
	}

  public:
	Segtree(int n) : sz(n), t(4 * n) {}

	void update(int ql, int qr, const Update &x) { update(1, 0, sz - 1, ql, qr, x); }

	Update get(int idx) { return query(1, 0, sz - 1, idx); }
};

void buildWall(int n, int k, int op[], int left[], int right[], int height[],
               int final_height[]) {
	Segtree st(n);
	for (int i = 0; i < k; i++) {
		if (op[i] == 1) {
			st.update(left[i], right[i], {height[i], INT_MAX});
		} else {
			st.update(left[i], right[i], {0, height[i]});
		}
	}
	for (int i = 0; i < n; i++) { final_height[i] = st.get(i).min_val; }
}
# 결과 실행 시간 메모리 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 4 ms 860 KB Output is correct
5 Correct 4 ms 860 KB Output is correct
6 Correct 4 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 81 ms 13908 KB Output is correct
3 Correct 118 ms 8020 KB Output is correct
4 Correct 348 ms 21348 KB Output is correct
5 Correct 212 ms 21800 KB Output is correct
6 Correct 248 ms 20308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 436 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 860 KB Output is correct
5 Correct 5 ms 860 KB Output is correct
6 Correct 4 ms 888 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 98 ms 13980 KB Output is correct
9 Correct 112 ms 8096 KB Output is correct
10 Correct 344 ms 21288 KB Output is correct
11 Correct 229 ms 21840 KB Output is correct
12 Correct 208 ms 20308 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 86 ms 13984 KB Output is correct
15 Correct 19 ms 1880 KB Output is correct
16 Correct 338 ms 21332 KB Output is correct
17 Correct 206 ms 20564 KB Output is correct
18 Correct 197 ms 20580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 572 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 5 ms 852 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 600 KB Output is correct
8 Correct 86 ms 14048 KB Output is correct
9 Correct 110 ms 7940 KB Output is correct
10 Correct 328 ms 21364 KB Output is correct
11 Correct 203 ms 21844 KB Output is correct
12 Correct 196 ms 20304 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 85 ms 13856 KB Output is correct
15 Correct 26 ms 2040 KB Output is correct
16 Correct 323 ms 21284 KB Output is correct
17 Correct 215 ms 20648 KB Output is correct
18 Correct 201 ms 20644 KB Output is correct
19 Correct 753 ms 89000 KB Output is correct
20 Correct 744 ms 88972 KB Output is correct
21 Correct 735 ms 88912 KB Output is correct
22 Correct 769 ms 88892 KB Output is correct
23 Correct 745 ms 88984 KB Output is correct
24 Correct 745 ms 89000 KB Output is correct
25 Correct 740 ms 88912 KB Output is correct
26 Correct 740 ms 89136 KB Output is correct
27 Correct 733 ms 88920 KB Output is correct
28 Correct 733 ms 89144 KB Output is correct
29 Correct 746 ms 89112 KB Output is correct
30 Correct 746 ms 88968 KB Output is correct