답안 #221808

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
221808 2020-04-11T07:58:07 Z patrikpavic2 벽 (IOI14_wall) C++17
100 / 100
1054 ms 69752 KB
/**
* user:  ppavic
* fname: Patrik
* lname: Pavić
* task:  wall
* score: 100.0
* date:  2019-06-25 09:50:17.292891
*/
#include "wall.h"
#include <cstdio>
#include <algorithm>

using namespace std;

const int OFF = (1 << 21);
const int INF = 0x3f3f3f3f;

int mx[2 * OFF ], mi[2 * OFF];

void spoji(int j,int i){
	int olmi = mi[i];
	mx[i] = min(mx[i], mx[j]);
	mi[i] = max(mi[i], mi[j]);
	//if(i == OFF + 1) printf("nov nov %d %d\n", mi[i], mx[i]);
	if(mi[i] > mx[i]){
		//if(i == OFF + 1) printf("tu sam %d %d\n", mi[i], mi[j]);
		if(olmi < mi[j])
			mx[i] = mi[i];
		else
			mi[i] = mx[i];
	}
}

void prop(int i){
	if(i < OFF){
		spoji(i, 2 * i);
		spoji(i, 2 * i + 1);
		mx[i] = INF, mi[i] = 0;
	}
}

void update(int i,int a,int b,int lo,int hi){
	prop(i);
	if(lo <= a && b <= hi){
		//printf("prije %d %d , dodaj %d %d\n", mi[i], mx[i], mi[0], mx[0]);
		spoji(0, i);
		//printf("I : %d A : %d B : %d => %d %d\n", i, a, b, mi[i], mx[i]);
		prop(i);
		return;
	}
	if(a > hi || b < lo) return;
	update(2 * i, a, (a + b) / 2, lo, hi);
	update(2 * i + 1, (a + b) / 2 + 1, b, lo, hi);


}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){

	for(int i = 0;i < k;i++){
		mi[0] = 0, mx[0] = INF;
		if(op[i] == 2) mx[0] = height[i];
		else           mi[0] = height[i];
		update(1, 0, OFF - 1, left[i], right[i]);
		//printf(" trenutno : ");
		//for(int i = 0;i < n;i++) printf("{%d %d} ", mi[OFF + i], mx[OFF + i]);
		//printf("\n\n");
	}
	for(int i = 1;i < OFF;i++) prop(i);
	for(int i = 0;i < n;i++) finalHeight[i] = mi[OFF + i];
	return;
}







# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 33144 KB Output is correct
2 Correct 41 ms 33272 KB Output is correct
3 Correct 44 ms 33148 KB Output is correct
4 Correct 46 ms 33400 KB Output is correct
5 Correct 45 ms 33408 KB Output is correct
6 Correct 44 ms 33400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 33144 KB Output is correct
2 Correct 414 ms 46840 KB Output is correct
3 Correct 309 ms 40312 KB Output is correct
4 Correct 756 ms 51192 KB Output is correct
5 Correct 510 ms 52252 KB Output is correct
6 Correct 506 ms 50680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 33144 KB Output is correct
2 Correct 44 ms 33272 KB Output is correct
3 Correct 41 ms 33148 KB Output is correct
4 Correct 47 ms 33400 KB Output is correct
5 Correct 45 ms 33400 KB Output is correct
6 Correct 45 ms 33360 KB Output is correct
7 Correct 39 ms 33144 KB Output is correct
8 Correct 438 ms 46840 KB Output is correct
9 Correct 300 ms 40312 KB Output is correct
10 Correct 744 ms 51320 KB Output is correct
11 Correct 497 ms 52348 KB Output is correct
12 Correct 472 ms 50680 KB Output is correct
13 Correct 43 ms 33148 KB Output is correct
14 Correct 436 ms 46816 KB Output is correct
15 Correct 89 ms 34424 KB Output is correct
16 Correct 947 ms 51496 KB Output is correct
17 Correct 497 ms 50956 KB Output is correct
18 Correct 499 ms 50808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 33144 KB Output is correct
2 Correct 42 ms 33272 KB Output is correct
3 Correct 41 ms 33144 KB Output is correct
4 Correct 47 ms 33400 KB Output is correct
5 Correct 48 ms 33400 KB Output is correct
6 Correct 45 ms 33400 KB Output is correct
7 Correct 38 ms 33144 KB Output is correct
8 Correct 410 ms 46840 KB Output is correct
9 Correct 306 ms 40500 KB Output is correct
10 Correct 737 ms 51192 KB Output is correct
11 Correct 500 ms 52216 KB Output is correct
12 Correct 499 ms 50668 KB Output is correct
13 Correct 39 ms 33144 KB Output is correct
14 Correct 449 ms 46840 KB Output is correct
15 Correct 88 ms 34296 KB Output is correct
16 Correct 955 ms 51416 KB Output is correct
17 Correct 506 ms 50808 KB Output is correct
18 Correct 496 ms 50808 KB Output is correct
19 Correct 1024 ms 69624 KB Output is correct
20 Correct 1054 ms 67196 KB Output is correct
21 Correct 1000 ms 69628 KB Output is correct
22 Correct 1006 ms 67024 KB Output is correct
23 Correct 1008 ms 67192 KB Output is correct
24 Correct 1012 ms 67272 KB Output is correct
25 Correct 1032 ms 67064 KB Output is correct
26 Correct 1006 ms 69752 KB Output is correct
27 Correct 1028 ms 69608 KB Output is correct
28 Correct 1032 ms 67176 KB Output is correct
29 Correct 1024 ms 67064 KB Output is correct
30 Correct 1040 ms 67192 KB Output is correct