답안 #1014088

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1014088 2024-07-04T10:36:20 Z DorostWef 벽 (IOI14_wall) C++17
100 / 100
487 ms 166228 KB
#include "wall.h"
#include <bits/stdc++.h>

using namespace std;
#define F first
#define S second

const int N = 500012, SegN = (1 << 20), INF = 1e7 + 190; 
pair <int, int> seg[SegN];
vector <int> s[N * 4], e[N * 4]; 
pair <int, int> p[N];
int kk = 0;

void build (int v = 1, int tl = 0, int tr = kk - 1) {
	seg[v] = {INF, -INF};
	if (tl != tr) {
		int mid = (tl + tr) >> 1;
		build (v << 1, tl, mid);
		build (v << 1 | 1, mid + 1, tr);
	}
}

pair <int, int> Merge (pair <int, int> p, pair <int, int> q) {
	pair <int, int> w;
	if (q.F >= p.F)
		w = p;
	else if (q.F <= p.S) {
		w = {q.F, q.F};
	} else {
		w = {q.F, p.S};
	}
	w.S = max (w.S, q.S);
	if (w.F <= w.S)
		w = {w.S, w.S};
	return w;
}

void upd (int i, int a, int b, int v = 1, int tl = 0, int tr = kk - 1) {
	if (tl == tr) {
		seg[v].F = a;
		seg[v].S = b;
		return;
	}
	int mid = (tl + tr) >> 1;
	if (i <= mid)
		upd (i, a, b, v << 1, tl, mid);
	else
		upd (i, a, b, v << 1 | 1, mid + 1, tr);
	seg[v] = Merge (seg[v << 1], seg[v << 1 | 1]);
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
	kk = k;
	build();
	for (int i = 0; i < k; i++) {
		s[left[i]].push_back(i);
		e[right[i]].push_back(i);
		if (op[i] == 1) {
			p[i].S = height[i];
			p[i].F = INF;
		} else {
			p[i].F = height[i];
			p[i].S = -INF;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j : s[i]) {
			upd (j, p[j].F, p[j].S);
		}
		int x = 0;
		x = min (x, seg[1].F);
		x = max (x, seg[1].S);
		finalHeight[i] = x;
		for (int j : e[i]) {
			upd (j, INF, -INF);
		}
	}
}

# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 94296 KB Output is correct
2 Correct 43 ms 94600 KB Output is correct
3 Correct 40 ms 94344 KB Output is correct
4 Correct 43 ms 94804 KB Output is correct
5 Correct 41 ms 94804 KB Output is correct
6 Correct 42 ms 94664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 94296 KB Output is correct
2 Correct 248 ms 118236 KB Output is correct
3 Correct 159 ms 106736 KB Output is correct
4 Correct 460 ms 124448 KB Output is correct
5 Correct 275 ms 122704 KB Output is correct
6 Correct 282 ms 122220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 94380 KB Output is correct
2 Correct 39 ms 94556 KB Output is correct
3 Correct 40 ms 94296 KB Output is correct
4 Correct 40 ms 94940 KB Output is correct
5 Correct 42 ms 94808 KB Output is correct
6 Correct 40 ms 94880 KB Output is correct
7 Correct 39 ms 94288 KB Output is correct
8 Correct 224 ms 118344 KB Output is correct
9 Correct 152 ms 106576 KB Output is correct
10 Correct 487 ms 124248 KB Output is correct
11 Correct 260 ms 122712 KB Output is correct
12 Correct 270 ms 122320 KB Output is correct
13 Correct 35 ms 94288 KB Output is correct
14 Correct 295 ms 118268 KB Output is correct
15 Correct 58 ms 96596 KB Output is correct
16 Correct 438 ms 124412 KB Output is correct
17 Correct 286 ms 121940 KB Output is correct
18 Correct 290 ms 121680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 94300 KB Output is correct
2 Correct 37 ms 94544 KB Output is correct
3 Correct 40 ms 94292 KB Output is correct
4 Correct 41 ms 94804 KB Output is correct
5 Correct 52 ms 94808 KB Output is correct
6 Correct 41 ms 94808 KB Output is correct
7 Correct 37 ms 94300 KB Output is correct
8 Correct 235 ms 118292 KB Output is correct
9 Correct 168 ms 106796 KB Output is correct
10 Correct 420 ms 124240 KB Output is correct
11 Correct 309 ms 122704 KB Output is correct
12 Correct 291 ms 122204 KB Output is correct
13 Correct 39 ms 94300 KB Output is correct
14 Correct 245 ms 118328 KB Output is correct
15 Correct 62 ms 96596 KB Output is correct
16 Correct 428 ms 124500 KB Output is correct
17 Correct 298 ms 121928 KB Output is correct
18 Correct 294 ms 121680 KB Output is correct
19 Correct 419 ms 155960 KB Output is correct
20 Correct 423 ms 163668 KB Output is correct
21 Correct 434 ms 166228 KB Output is correct
22 Correct 416 ms 163924 KB Output is correct
23 Correct 408 ms 163664 KB Output is correct
24 Correct 407 ms 163920 KB Output is correct
25 Correct 386 ms 163668 KB Output is correct
26 Correct 383 ms 166228 KB Output is correct
27 Correct 396 ms 166228 KB Output is correct
28 Correct 401 ms 163664 KB Output is correct
29 Correct 456 ms 163668 KB Output is correct
30 Correct 422 ms 163780 KB Output is correct