Submission #113252

# Submission time Handle Problem Language Result Execution time Memory
113252 2019-05-24T12:35:39 Z njchung99 Wall (IOI14_wall) C++14
100 / 100
1275 ms 69496 KB
#include "wall.h"
#include<cstdio>
#include<algorithm>
using namespace std;
int mi[8000000], ma[8000000];
int *dap;
void update(int lo, int hi, int val, int node, int x, int y, int p) {
	if (hi < x || y < lo)return;
	if (lo <= x && y <= hi) {
		if (p == 1) {
			mi[node] = max(mi[node], val);
			ma[node] = max(ma[node], val);
		}
		else if (p == 2)
		{
			mi[node] = min(mi[node], val);
			ma[node] = min(ma[node], val);
		}
		if (x == y)
			dap[x] = ma[node];
		return;
	}
	int ll = node * 2;
	int rr = node * 2 + 1;
	int mid = (x + y) / 2;
	mi[ll] = min(mi[ll], mi[node]); mi[rr] = min(mi[rr], mi[node]);
	ma[ll] = min(ma[ll], mi[node]); ma[rr] = min(ma[rr], mi[node]);
	mi[ll] = max(mi[ll], ma[node]); mi[rr] = max(mi[rr], ma[node]);
	ma[ll] = max(ma[ll], ma[node]); ma[rr] = max(ma[rr], ma[node]);
	ma[node] = 0; mi[node] = 1234567890;
	update(lo, hi, val, node * 2, x, mid, p);
	update(lo, hi, val, node * 2 + 1, mid + 1, y, p);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) {
	dap = finalHeight;
	for (int i = 0; i < k; ++i) {
		update(left[i], right[i], height[i], 1, 0, n - 1, op[i]);
	}
	for (int i = 0; i < n; ++i)
		update(i, i, 0, 1, 0, n - 1, 0);
	return;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 8 ms 896 KB Output is correct
5 Correct 8 ms 896 KB Output is correct
6 Correct 8 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 146 ms 8156 KB Output is correct
3 Correct 173 ms 4268 KB Output is correct
4 Correct 549 ms 20460 KB Output is correct
5 Correct 300 ms 21496 KB Output is correct
6 Correct 294 ms 19884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 356 KB Output is correct
4 Correct 8 ms 896 KB Output is correct
5 Correct 9 ms 896 KB Output is correct
6 Correct 9 ms 896 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 155 ms 13916 KB Output is correct
9 Correct 164 ms 8056 KB Output is correct
10 Correct 569 ms 20576 KB Output is correct
11 Correct 296 ms 21496 KB Output is correct
12 Correct 293 ms 19960 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 140 ms 13944 KB Output is correct
15 Correct 31 ms 2168 KB Output is correct
16 Correct 513 ms 20700 KB Output is correct
17 Correct 296 ms 20088 KB Output is correct
18 Correct 307 ms 20216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 8 ms 896 KB Output is correct
5 Correct 8 ms 896 KB Output is correct
6 Correct 8 ms 896 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 149 ms 13960 KB Output is correct
9 Correct 226 ms 8056 KB Output is correct
10 Correct 501 ms 20488 KB Output is correct
11 Correct 298 ms 21612 KB Output is correct
12 Correct 297 ms 20008 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 153 ms 13980 KB Output is correct
15 Correct 33 ms 2048 KB Output is correct
16 Correct 596 ms 20780 KB Output is correct
17 Correct 297 ms 20216 KB Output is correct
18 Correct 306 ms 20220 KB Output is correct
19 Correct 1275 ms 69496 KB Output is correct
20 Correct 1130 ms 67232 KB Output is correct
21 Correct 1128 ms 69284 KB Output is correct
22 Correct 1124 ms 66936 KB Output is correct
23 Correct 1127 ms 66912 KB Output is correct
24 Correct 1127 ms 66936 KB Output is correct
25 Correct 1255 ms 67068 KB Output is correct
26 Correct 1261 ms 69492 KB Output is correct
27 Correct 1261 ms 69488 KB Output is correct
28 Correct 1237 ms 66980 KB Output is correct
29 Correct 1160 ms 67048 KB Output is correct
30 Correct 1230 ms 66944 KB Output is correct