Submission #296917

# Submission time Handle Problem Language Result Execution time Memory
296917 2020-09-11T04:58:14 Z tmwilliamlin168 Wall (IOI14_wall) C++14
100 / 100
805 ms 69752 KB
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;

int stl[1<<22], str[1<<22];

void app(int i, int xl, int xr) {
	stl[i]=min(max(stl[i], xl), xr);
	str[i]=min(max(str[i], xl), xr);
}

void psh(int i) {
	app(2*i, stl[i], str[i]);
	app(2*i+1, stl[i], str[i]);
	stl[i]=0;
	str[i]=1e5;
}

void upd(int l1, int r1, int xl, int xr, int i, int l2, int r2) {
	if(l1<=l2&&r2<=r1) {
		app(i, xl, xr);
		return;
	}
	int m2=(l2+r2)/2;
	psh(i);
	if(l1<=m2)
		upd(l1, r1, xl, xr, 2*i, l2, m2);
	if(m2<r1)
		upd(l1, r1, xl, xr, 2*i+1, m2+1, r2);
}

void bld(int* x, int i, int l2, int r2) {
	if(l2==r2) {
		x[l2]=stl[i];
		return;
	}
	int m2=(l2+r2)/2;
	psh(i);
	bld(x, 2*i, l2, m2);
	bld(x, 2*i+1, m2+1, r2);
}

void buildWall(int n, int k, int* op, int* left, int* right, int* height, int* finalHeight) {
	for(int i=0; i<k; ++i)
		upd(left[i], right[i], op[i]^2?height[i]:0, op[i]^1?height[i]:1e5, 1, 0, n-1);
	bld(finalHeight, 1, 0, n-1);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 6 ms 896 KB Output is correct
5 Correct 7 ms 1024 KB Output is correct
6 Correct 6 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 165 ms 8312 KB Output is correct
3 Correct 181 ms 4344 KB Output is correct
4 Correct 514 ms 20600 KB Output is correct
5 Correct 331 ms 21500 KB Output is correct
6 Correct 311 ms 19960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 6 ms 896 KB Output is correct
5 Correct 6 ms 896 KB Output is correct
6 Correct 6 ms 1024 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 171 ms 13944 KB Output is correct
9 Correct 185 ms 8184 KB Output is correct
10 Correct 531 ms 20400 KB Output is correct
11 Correct 330 ms 21528 KB Output is correct
12 Correct 311 ms 19960 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 171 ms 13944 KB Output is correct
15 Correct 32 ms 2040 KB Output is correct
16 Correct 523 ms 20924 KB Output is correct
17 Correct 337 ms 20088 KB Output is correct
18 Correct 326 ms 20088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 6 ms 896 KB Output is correct
5 Correct 6 ms 896 KB Output is correct
6 Correct 6 ms 896 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 174 ms 13948 KB Output is correct
9 Correct 189 ms 8056 KB Output is correct
10 Correct 541 ms 20472 KB Output is correct
11 Correct 330 ms 21496 KB Output is correct
12 Correct 313 ms 20192 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 175 ms 13944 KB Output is correct
15 Correct 35 ms 2048 KB Output is correct
16 Correct 526 ms 20792 KB Output is correct
17 Correct 335 ms 20084 KB Output is correct
18 Correct 313 ms 20088 KB Output is correct
19 Correct 805 ms 69752 KB Output is correct
20 Correct 763 ms 67064 KB Output is correct
21 Correct 771 ms 69752 KB Output is correct
22 Correct 763 ms 67064 KB Output is correct
23 Correct 760 ms 67064 KB Output is correct
24 Correct 771 ms 67064 KB Output is correct
25 Correct 773 ms 67208 KB Output is correct
26 Correct 771 ms 69624 KB Output is correct
27 Correct 777 ms 69752 KB Output is correct
28 Correct 787 ms 67160 KB Output is correct
29 Correct 757 ms 67192 KB Output is correct
30 Correct 764 ms 67140 KB Output is correct