Submission #109964

# Submission time Handle Problem Language Result Execution time Memory
109964 2019-05-08T13:05:11 Z DodgeBallMan Wall (IOI14_wall) C++14
100 / 100
913 ms 69500 KB
#include "wall.h"
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 1 << 21;
 
int lo[N << 1], hi[N << 1];
int *ret, S;
 
void puttag(int p, int low, int high) {
	lo[p] = min(high, max(low, lo[p]));
	hi[p] = max(low, min(high, hi[p]));
}
 
void pushlz(int p, int l, int r) {
	if(l == r) ret[l] = min(hi[p], max(lo[p], ret[l]));
	else {
		puttag(p << 1, lo[p], hi[p]);
		puttag(p << 1 | 1, lo[p], hi[p]);
	}
	lo[p] = 0;
	hi[p] = INT_MAX;
}
 
void build(int p = 1, int l = 0, int r = S - 1) {
	hi[p] = INT_MAX;
	if(l == r) return;
	int mid = (l + r) >> 1;
	build(p << 1, l, mid);
	build(p << 1 | 1, mid + 1, r);
}
 
void update(int x, int y, int low, int high, int p = 1, int l = 0, int r = S - 1) {
  	pushlz(p, l, r);
	if(x > r || l > y) return;
	if(x <= l && r <= y) return puttag(p, low, high);
	int mid = (l + r) >> 1;
	update(x, y, low, high, p << 1, l, mid);
	update(x, y, low, high, p << 1 | 1, mid + 1, r);
}
 
void proc(int p = 1, int l = 0, int r = S - 1) {
	pushlz(p, l, r);
	if(l == r) return;
	int mid = (l + r) >> 1;
	proc(p << 1, l, mid);
	proc(p << 1 | 1, mid + 1, r);
}
 
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
	ret = finalHeight;
	S = n;
	build();
	for(int i = 0; i < k; i++) {
		if(op[i] == 1) update(left[i], right[i], height[i], INT_MAX);
		else if(op[i] == 2) update(left[i], right[i], 0, height[i]);
	}
	proc();
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 8 ms 768 KB Output is correct
5 Correct 12 ms 768 KB Output is correct
6 Correct 7 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 187 ms 8276 KB Output is correct
3 Correct 245 ms 4216 KB Output is correct
4 Correct 721 ms 10872 KB Output is correct
5 Correct 365 ms 11440 KB Output is correct
6 Correct 349 ms 19960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 8 ms 768 KB Output is correct
5 Correct 8 ms 768 KB Output is correct
6 Correct 8 ms 796 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 209 ms 13944 KB Output is correct
9 Correct 194 ms 8056 KB Output is correct
10 Correct 684 ms 20488 KB Output is correct
11 Correct 499 ms 21596 KB Output is correct
12 Correct 534 ms 20072 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 175 ms 13944 KB Output is correct
15 Correct 37 ms 2048 KB Output is correct
16 Correct 852 ms 20640 KB Output is correct
17 Correct 371 ms 20096 KB Output is correct
18 Correct 371 ms 20088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 8 ms 768 KB Output is correct
5 Correct 12 ms 768 KB Output is correct
6 Correct 10 ms 768 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 174 ms 13944 KB Output is correct
9 Correct 187 ms 8056 KB Output is correct
10 Correct 603 ms 20436 KB Output is correct
11 Correct 342 ms 21496 KB Output is correct
12 Correct 342 ms 19960 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 178 ms 13916 KB Output is correct
15 Correct 46 ms 2040 KB Output is correct
16 Correct 575 ms 20684 KB Output is correct
17 Correct 402 ms 20124 KB Output is correct
18 Correct 330 ms 20088 KB Output is correct
19 Correct 879 ms 69388 KB Output is correct
20 Correct 887 ms 66936 KB Output is correct
21 Correct 829 ms 69500 KB Output is correct
22 Correct 738 ms 67064 KB Output is correct
23 Correct 882 ms 66848 KB Output is correct
24 Correct 778 ms 66920 KB Output is correct
25 Correct 767 ms 66892 KB Output is correct
26 Correct 802 ms 69368 KB Output is correct
27 Correct 913 ms 69376 KB Output is correct
28 Correct 720 ms 66808 KB Output is correct
29 Correct 886 ms 66800 KB Output is correct
30 Correct 885 ms 67064 KB Output is correct