답안 #737533

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
737533 2023-05-07T09:56:12 Z esomer 벽 (IOI14_wall) C++17
100 / 100
938 ms 59300 KB
#include<bits/stdc++.h>
 
using namespace std;

struct segTree{
	vector<pair<int, int>> v;
	int siz;
	void init(int n){
		siz = 1;
		while(siz < n) siz *= 2;
		v.assign(2 * siz, {0, 0});
	}
	void push(int x){
		v[2 * x + 1].first = min(max(v[2 * x + 1].first, v[x].first), v[x].second);
		v[2 * x + 1].second = max(min(v[2 * x + 1].second, v[x].second), v[x].first);
		v[2 * x + 2].first = min(max(v[2 * x + 2].first, v[x].first), v[x].second);
		v[2 * x + 2].second = max(min(v[2 * x + 2].second, v[x].second), v[x].first);
	}
	void set(int l, int r, int x, int lx, int rx, int h, int t){
		if(lx >= l && rx <= r){
			if(t == 1){
				v[x].first = max(v[x].first, h);
				v[x].second = max(v[x].second, v[x].first);
			}else{
				v[x].second = min(v[x].second, h);
				v[x].first = min(v[x].first, v[x].second);
			}
			return;
		}else if(lx >= r || rx <= l) return;
		push(x);
		v[x] = {0, 100000};
		int m = (lx + rx) / 2;
		set(l, r, 2 * x + 1, lx, m, h, t);
		set(l, r, 2 * x + 2, m, rx, h, t);
	}
	void set(int l, int r, int h, int t){
		set(l, r, 0, 0, siz, h, t);
	}
	int calc(int i, int x, int lx, int rx){
		if(rx - lx == 1){
			return v[x].first;
		}
		push(x);
		v[x] = {0, 100000};
		int m = (lx + rx) / 2;
		if(i < m) return calc(i, 2 * x + 1, lx, m);
		else return calc(i, 2 * x + 2, m, rx);
	}
	int calc(int i){
		return calc(i, 0, 0, siz);
	}
};

//~ int op[1000];
//~ int lft[1000];
//~ int rght[1000];
//~ int height[1000];
//~ int finalHeight[1000];

void buildWall(int n, int k, int* op, int* left, int* right,int* height, int* finalHeight){
	segTree st; st.init(n);
	for(int i = 0; i < k; i++){
		st.set(left[i], right[i] + 1, height[i], op[i]);
	}
	for(int i = 0; i < n; i++){
		finalHeight[i] = st.calc(i);
	}
}

//~ int main(){
	//~ int n, k; cin >> n >> k;
	//~ for(int i = 0; i < k; i++){
		//~ cin >> op[i] >> lft[i] >> rght[i] >> height[i];
	//~ }
	//~ buildWall(n, k);
	//~ for(int i = 0; i < n; i++){
		//~ cout << finalHeight[i] << " ";
	//~ }
//~ }
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 436 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 6 ms 724 KB Output is correct
5 Correct 6 ms 724 KB Output is correct
6 Correct 8 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 145 ms 13900 KB Output is correct
3 Correct 154 ms 7884 KB Output is correct
4 Correct 373 ms 20072 KB Output is correct
5 Correct 287 ms 20720 KB Output is correct
6 Correct 279 ms 19164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 436 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 6 ms 756 KB Output is correct
5 Correct 5 ms 696 KB Output is correct
6 Correct 6 ms 724 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 156 ms 13888 KB Output is correct
9 Correct 148 ms 7880 KB Output is correct
10 Correct 411 ms 20176 KB Output is correct
11 Correct 264 ms 20724 KB Output is correct
12 Correct 298 ms 19268 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 133 ms 13908 KB Output is correct
15 Correct 29 ms 1840 KB Output is correct
16 Correct 437 ms 20180 KB Output is correct
17 Correct 274 ms 19504 KB Output is correct
18 Correct 268 ms 19536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 6 ms 724 KB Output is correct
5 Correct 5 ms 724 KB Output is correct
6 Correct 7 ms 692 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 126 ms 13924 KB Output is correct
9 Correct 150 ms 7892 KB Output is correct
10 Correct 406 ms 20084 KB Output is correct
11 Correct 281 ms 20728 KB Output is correct
12 Correct 259 ms 19120 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 145 ms 13816 KB Output is correct
15 Correct 30 ms 1864 KB Output is correct
16 Correct 485 ms 20180 KB Output is correct
17 Correct 304 ms 19600 KB Output is correct
18 Correct 288 ms 19516 KB Output is correct
19 Correct 938 ms 59192 KB Output is correct
20 Correct 902 ms 59300 KB Output is correct
21 Correct 889 ms 59112 KB Output is correct
22 Correct 923 ms 59276 KB Output is correct
23 Correct 899 ms 59220 KB Output is correct
24 Correct 917 ms 59108 KB Output is correct
25 Correct 893 ms 59160 KB Output is correct
26 Correct 858 ms 59188 KB Output is correct
27 Correct 890 ms 59220 KB Output is correct
28 Correct 870 ms 59128 KB Output is correct
29 Correct 912 ms 59164 KB Output is correct
30 Correct 875 ms 59144 KB Output is correct