답안 #1087706

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1087706 2024-09-13T06:15:28 Z cryan 벽 (IOI14_wall) C++17
100 / 100
773 ms 89172 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 push_down(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 {
			push_down(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 {
			push_down(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 5 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 344 KB Output is correct
2 Correct 82 ms 14060 KB Output is correct
3 Correct 114 ms 8016 KB Output is correct
4 Correct 319 ms 21176 KB Output is correct
5 Correct 204 ms 21840 KB Output is correct
6 Correct 189 ms 20280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 5 ms 856 KB Output is correct
5 Correct 4 ms 892 KB Output is correct
6 Correct 5 ms 856 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 80 ms 13972 KB Output is correct
9 Correct 110 ms 8088 KB Output is correct
10 Correct 327 ms 21284 KB Output is correct
11 Correct 207 ms 21844 KB Output is correct
12 Correct 210 ms 20160 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 88 ms 13872 KB Output is correct
15 Correct 31 ms 2040 KB Output is correct
16 Correct 338 ms 21332 KB Output is correct
17 Correct 210 ms 20816 KB Output is correct
18 Correct 213 ms 20776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 496 KB Output is correct
4 Correct 5 ms 960 KB Output is correct
5 Correct 4 ms 860 KB Output is correct
6 Correct 4 ms 860 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 82 ms 13932 KB Output is correct
9 Correct 116 ms 8028 KB Output is correct
10 Correct 338 ms 21232 KB Output is correct
11 Correct 225 ms 21892 KB Output is correct
12 Correct 195 ms 20148 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 85 ms 14064 KB Output is correct
15 Correct 20 ms 1880 KB Output is correct
16 Correct 345 ms 21328 KB Output is correct
17 Correct 206 ms 20676 KB Output is correct
18 Correct 201 ms 20772 KB Output is correct
19 Correct 737 ms 88920 KB Output is correct
20 Correct 725 ms 88916 KB Output is correct
21 Correct 739 ms 89000 KB Output is correct
22 Correct 745 ms 88916 KB Output is correct
23 Correct 773 ms 89000 KB Output is correct
24 Correct 763 ms 88936 KB Output is correct
25 Correct 754 ms 89016 KB Output is correct
26 Correct 747 ms 88936 KB Output is correct
27 Correct 764 ms 89172 KB Output is correct
28 Correct 745 ms 88988 KB Output is correct
29 Correct 723 ms 88912 KB Output is correct
30 Correct 720 ms 88916 KB Output is correct