Submission #222283

# Submission time Handle Problem Language Result Execution time Memory
222283 2020-04-13T01:43:48 Z MODDI Wall (IOI14_wall) C++14
100 / 100
1062 ms 69648 KB
#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(mi[i] > mx[i]){
		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){
		spoji(0, 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]);
	}
	for(int i = 1;i < OFF;i++) prop(i);
	for(int i = 0;i < n;i++) finalHeight[i] = mi[OFF + i];
	return;
}
# Verdict Execution time Memory Grader output
1 Correct 40 ms 33144 KB Output is correct
2 Correct 45 ms 33272 KB Output is correct
3 Correct 43 ms 33144 KB Output is correct
4 Correct 49 ms 33400 KB Output is correct
5 Correct 47 ms 33400 KB Output is correct
6 Correct 51 ms 33400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 33144 KB Output is correct
2 Correct 461 ms 41304 KB Output is correct
3 Correct 310 ms 37368 KB Output is correct
4 Correct 713 ms 41720 KB Output is correct
5 Correct 517 ms 52216 KB Output is correct
6 Correct 532 ms 50680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 33144 KB Output is correct
2 Correct 48 ms 33272 KB Output is correct
3 Correct 46 ms 33144 KB Output is correct
4 Correct 53 ms 33400 KB Output is correct
5 Correct 51 ms 33400 KB Output is correct
6 Correct 47 ms 33400 KB Output is correct
7 Correct 40 ms 33144 KB Output is correct
8 Correct 449 ms 41464 KB Output is correct
9 Correct 315 ms 37368 KB Output is correct
10 Correct 736 ms 41692 KB Output is correct
11 Correct 492 ms 52216 KB Output is correct
12 Correct 480 ms 50600 KB Output is correct
13 Correct 41 ms 33144 KB Output is correct
14 Correct 427 ms 46948 KB Output is correct
15 Correct 90 ms 34296 KB Output is correct
16 Correct 967 ms 51448 KB Output is correct
17 Correct 516 ms 51064 KB Output is correct
18 Correct 496 ms 50808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 33128 KB Output is correct
2 Correct 43 ms 33272 KB Output is correct
3 Correct 42 ms 33144 KB Output is correct
4 Correct 48 ms 33400 KB Output is correct
5 Correct 48 ms 33400 KB Output is correct
6 Correct 46 ms 33400 KB Output is correct
7 Correct 48 ms 33272 KB Output is correct
8 Correct 450 ms 41256 KB Output is correct
9 Correct 297 ms 37368 KB Output is correct
10 Correct 736 ms 41892 KB Output is correct
11 Correct 530 ms 52248 KB Output is correct
12 Correct 482 ms 50680 KB Output is correct
13 Correct 39 ms 33144 KB Output is correct
14 Correct 420 ms 46712 KB Output is correct
15 Correct 90 ms 34552 KB Output is correct
16 Correct 961 ms 51576 KB Output is correct
17 Correct 496 ms 50808 KB Output is correct
18 Correct 498 ms 50952 KB Output is correct
19 Correct 1000 ms 69624 KB Output is correct
20 Correct 1024 ms 67352 KB Output is correct
21 Correct 1012 ms 69624 KB Output is correct
22 Correct 993 ms 67320 KB Output is correct
23 Correct 1022 ms 67128 KB Output is correct
24 Correct 1029 ms 67024 KB Output is correct
25 Correct 1002 ms 67008 KB Output is correct
26 Correct 1022 ms 69648 KB Output is correct
27 Correct 1024 ms 69496 KB Output is correct
28 Correct 1062 ms 66964 KB Output is correct
29 Correct 1018 ms 67104 KB Output is correct
30 Correct 1031 ms 67192 KB Output is correct