답안 #7406

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
7406 2014-08-05T03:05:07 Z ainta 벽 (IOI14_wall) C++
100 / 100
992 ms 57688 KB
#include "wall.h"
#include<algorithm>
using namespace std;
#define SZ 2097152
int Res[SZ], N;
struct SegTree{
	int B, E;
}IT[SZ*2+2];
void spread(int node){
	IT[node * 2].B = min(max(IT[node * 2].B, IT[node].B), IT[node].E);
	IT[node * 2 + 1].B = min(max(IT[node * 2 + 1].B, IT[node].B), IT[node].E);
	IT[node * 2].E = min(max(IT[node * 2].E, IT[node].B), IT[node].E);
	IT[node * 2 + 1].E = min(max(IT[node * 2 + 1].E, IT[node].B), IT[node].E);
}
void UDT(int node){
	IT[node].B = min(IT[node * 2].B, IT[node * 2 + 1].B);
	IT[node].E = max(IT[node * 2].E, IT[node * 2 + 1].E);
}
void Ins(int node, int b, int e, int s, int l, int h, int ck){
	if (b == s && e == l){
		if (ck == 1){
			IT[node].B = max(IT[node].B, h);
			IT[node].E = max(IT[node].E, h);
		}
		else{
			IT[node].B = min(IT[node].B, h);
			IT[node].E = min(IT[node].E, h);
		}
		return;
	}
	spread(node);
	int m = (b + e) >> 1;
	if (s <= m)Ins(node * 2, b, m, s, min(m, l), h, ck);
	if (l > m)Ins(node * 2 + 1, m + 1, e, max(m + 1, s), l, h, ck);
	UDT(node);
}

void Do(int node, int b, int e){
	if (b >= N)return;
	if (b == e){
		Res[b] = IT[node].B;
		return;
	}
	spread(node);
	int m = (b + e) >> 1;
	Do(node * 2, b, m);
	Do(node * 2 + 1, m + 1, e);
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
	int i;
	N = n;
	for (i = 0; i < k; i++){
		Ins(1, 0, SZ - 1, left[i], right[i], height[i], op[i]);
	}
	Do(1, 0, SZ-1);
	for (i = 0; i < n; i++)finalHeight[i] = Res[i];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 42048 KB Output is correct
2 Correct 4 ms 42048 KB Output is correct
3 Correct 0 ms 42048 KB Output is correct
4 Correct 4 ms 42048 KB Output is correct
5 Correct 8 ms 42048 KB Output is correct
6 Correct 8 ms 42048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 42048 KB Output is correct
2 Correct 436 ms 49872 KB Output is correct
3 Correct 260 ms 45296 KB Output is correct
4 Correct 744 ms 50264 KB Output is correct
5 Correct 492 ms 50264 KB Output is correct
6 Correct 444 ms 50264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 42048 KB Output is correct
2 Correct 4 ms 42048 KB Output is correct
3 Correct 0 ms 42048 KB Output is correct
4 Correct 8 ms 42048 KB Output is correct
5 Correct 4 ms 42048 KB Output is correct
6 Correct 8 ms 42048 KB Output is correct
7 Correct 0 ms 42048 KB Output is correct
8 Correct 436 ms 49872 KB Output is correct
9 Correct 272 ms 45296 KB Output is correct
10 Correct 740 ms 50264 KB Output is correct
11 Correct 460 ms 50264 KB Output is correct
12 Correct 468 ms 50264 KB Output is correct
13 Correct 0 ms 42048 KB Output is correct
14 Correct 424 ms 49872 KB Output is correct
15 Correct 44 ms 42532 KB Output is correct
16 Correct 792 ms 50264 KB Output is correct
17 Correct 480 ms 50264 KB Output is correct
18 Correct 484 ms 50264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 42048 KB Output is correct
2 Correct 0 ms 42048 KB Output is correct
3 Correct 0 ms 42048 KB Output is correct
4 Correct 8 ms 42048 KB Output is correct
5 Correct 8 ms 42048 KB Output is correct
6 Correct 8 ms 42048 KB Output is correct
7 Correct 0 ms 42048 KB Output is correct
8 Correct 452 ms 49872 KB Output is correct
9 Correct 272 ms 45296 KB Output is correct
10 Correct 740 ms 50264 KB Output is correct
11 Correct 472 ms 50264 KB Output is correct
12 Correct 456 ms 50264 KB Output is correct
13 Correct 0 ms 42048 KB Output is correct
14 Correct 436 ms 49872 KB Output is correct
15 Correct 48 ms 42532 KB Output is correct
16 Correct 808 ms 50264 KB Output is correct
17 Correct 476 ms 50264 KB Output is correct
18 Correct 452 ms 50264 KB Output is correct
19 Correct 984 ms 57688 KB Output is correct
20 Correct 980 ms 57688 KB Output is correct
21 Correct 980 ms 57688 KB Output is correct
22 Correct 956 ms 57688 KB Output is correct
23 Correct 964 ms 57688 KB Output is correct
24 Correct 956 ms 57688 KB Output is correct
25 Correct 940 ms 57688 KB Output is correct
26 Correct 944 ms 57688 KB Output is correct
27 Correct 980 ms 57688 KB Output is correct
28 Correct 968 ms 57688 KB Output is correct
29 Correct 992 ms 57688 KB Output is correct
30 Correct 956 ms 57688 KB Output is correct