답안 #440645

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
440645 2021-07-02T15:34:21 Z Elegia 밀림 점프 (APIO21_jumps) C++17
48 / 100
1133 ms 46436 KB
#include "jumps.h"

const int MAX_N = 200010, L = 18;

int N;
int h[MAX_N], left[MAX_N][L], right[MAX_N][L], gr[MAX_N][L];

void init(int _N, std::vector<int> _H) {
	N = _N;
	std::copy(_H.begin(), _H.end(), h + 1);
	static int stack[MAX_N], ord[MAX_N];
	int cnt = 0;
	for (int i = 1; i <= N; ++i) {
		while (cnt && h[i] > h[stack[cnt]])
			right[stack[cnt--]][0] = i;
		left[i][0] = stack[cnt];
		stack[++cnt] = i;
	}
	for (int i = 1; i <= N; ++i) for (int j = 1; j != L; ++j)
		left[i][j] = left[left[i][j - 1]][j - 1];
	std::fill(right[N + 1], right[N + 1] + L, N + 1);
	for (int i = N; i; --i) {
		if (!right[i][0]) right[i][0] = N + 1;
		for (int j = 1; j != L; ++j)
			right[i][j] = right[right[i][j - 1]][j - 1];
	}
	for (int i = 1; i <= N; ++i) ord[h[i]] = i;
	std::fill(gr[N + 1], gr[N + 1] + L, N + 1);
	for (int i = N; i; --i) {
		int j = ord[i];
		gr[j][0] = (h[left[j][0]] > h[right[j][0]] ? left : right)[j][0];
		for (int k = 1; k != L; ++k) gr[j][k] = gr[gr[j][k - 1]][k - 1];
	}
}

int minimum_jumps(int A, int B, int C, int D) {
	++A; ++B; ++C; ++D;
	for (int i = L - 1; i >= 0; --i) if (left[D][i] >= C)
		D = left[D][i];
	for (int i = L - 1; i >= 0; --i) if (left[B][i] >= A && h[left[B][i]] < h[D])
		B = left[B][i];
	int ret = 1;
	for (int i = L - 1; i >= 0; --i) if (gr[B][i] < C && h[gr[B][i]] < h[C]) {
		ret += 1 << i;
		B = gr[B][i];
	}
	for (int i = L - 1; i >= 0; --i) if (right[B][i] < C) {
		ret += 1 << i;
		B = right[B][i];
	}
	if (h[B] > h[D]) return -1;
	return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 180 ms 36416 KB Output is correct
4 Correct 1123 ms 45588 KB Output is correct
5 Correct 960 ms 23108 KB Output is correct
6 Correct 1043 ms 45584 KB Output is correct
7 Correct 730 ms 31296 KB Output is correct
8 Correct 1038 ms 45624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 2 ms 200 KB Output is correct
6 Incorrect 2 ms 328 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 2 ms 200 KB Output is correct
6 Incorrect 2 ms 328 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 103 ms 36748 KB Output is correct
6 Correct 132 ms 45632 KB Output is correct
7 Correct 61 ms 23492 KB Output is correct
8 Correct 144 ms 45680 KB Output is correct
9 Correct 16 ms 7160 KB Output is correct
10 Correct 130 ms 45592 KB Output is correct
11 Correct 88 ms 45632 KB Output is correct
12 Correct 86 ms 45600 KB Output is correct
13 Incorrect 93 ms 45588 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 269 ms 21012 KB Output is correct
5 Correct 1016 ms 45668 KB Output is correct
6 Correct 548 ms 7752 KB Output is correct
7 Correct 1113 ms 45632 KB Output is correct
8 Correct 593 ms 15808 KB Output is correct
9 Correct 1054 ms 45712 KB Output is correct
10 Correct 988 ms 45632 KB Output is correct
11 Correct 1119 ms 45588 KB Output is correct
12 Correct 1133 ms 45632 KB Output is correct
13 Correct 1022 ms 45760 KB Output is correct
14 Correct 842 ms 46056 KB Output is correct
15 Correct 997 ms 46356 KB Output is correct
16 Correct 1028 ms 46400 KB Output is correct
17 Correct 0 ms 200 KB Output is correct
18 Correct 0 ms 200 KB Output is correct
19 Correct 2 ms 200 KB Output is correct
20 Correct 1 ms 328 KB Output is correct
21 Correct 2 ms 328 KB Output is correct
22 Correct 2 ms 328 KB Output is correct
23 Correct 2 ms 328 KB Output is correct
24 Correct 2 ms 328 KB Output is correct
25 Correct 0 ms 328 KB Output is correct
26 Correct 1 ms 456 KB Output is correct
27 Correct 20 ms 712 KB Output is correct
28 Correct 18 ms 712 KB Output is correct
29 Correct 21 ms 712 KB Output is correct
30 Correct 19 ms 712 KB Output is correct
31 Correct 19 ms 712 KB Output is correct
32 Correct 0 ms 200 KB Output is correct
33 Correct 72 ms 26540 KB Output is correct
34 Correct 143 ms 45668 KB Output is correct
35 Correct 89 ms 45584 KB Output is correct
36 Correct 117 ms 45632 KB Output is correct
37 Correct 110 ms 46056 KB Output is correct
38 Correct 87 ms 46344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 269 ms 21012 KB Output is correct
5 Correct 1016 ms 45668 KB Output is correct
6 Correct 548 ms 7752 KB Output is correct
7 Correct 1113 ms 45632 KB Output is correct
8 Correct 593 ms 15808 KB Output is correct
9 Correct 1054 ms 45712 KB Output is correct
10 Correct 988 ms 45632 KB Output is correct
11 Correct 1119 ms 45588 KB Output is correct
12 Correct 1133 ms 45632 KB Output is correct
13 Correct 1022 ms 45760 KB Output is correct
14 Correct 842 ms 46056 KB Output is correct
15 Correct 997 ms 46356 KB Output is correct
16 Correct 1028 ms 46400 KB Output is correct
17 Correct 0 ms 200 KB Output is correct
18 Correct 0 ms 200 KB Output is correct
19 Correct 2 ms 200 KB Output is correct
20 Correct 1 ms 328 KB Output is correct
21 Correct 2 ms 328 KB Output is correct
22 Correct 2 ms 328 KB Output is correct
23 Correct 2 ms 328 KB Output is correct
24 Correct 2 ms 328 KB Output is correct
25 Correct 0 ms 328 KB Output is correct
26 Correct 1 ms 456 KB Output is correct
27 Correct 20 ms 712 KB Output is correct
28 Correct 18 ms 712 KB Output is correct
29 Correct 21 ms 712 KB Output is correct
30 Correct 19 ms 712 KB Output is correct
31 Correct 19 ms 712 KB Output is correct
32 Correct 0 ms 200 KB Output is correct
33 Correct 72 ms 26540 KB Output is correct
34 Correct 143 ms 45668 KB Output is correct
35 Correct 89 ms 45584 KB Output is correct
36 Correct 117 ms 45632 KB Output is correct
37 Correct 110 ms 46056 KB Output is correct
38 Correct 87 ms 46344 KB Output is correct
39 Correct 0 ms 200 KB Output is correct
40 Correct 0 ms 200 KB Output is correct
41 Correct 0 ms 200 KB Output is correct
42 Correct 277 ms 21008 KB Output is correct
43 Correct 1032 ms 45632 KB Output is correct
44 Correct 620 ms 7752 KB Output is correct
45 Correct 1043 ms 45680 KB Output is correct
46 Correct 623 ms 15896 KB Output is correct
47 Correct 1035 ms 45684 KB Output is correct
48 Correct 1090 ms 45708 KB Output is correct
49 Correct 1016 ms 45568 KB Output is correct
50 Correct 1101 ms 45632 KB Output is correct
51 Correct 1038 ms 45632 KB Output is correct
52 Correct 1115 ms 46144 KB Output is correct
53 Correct 1034 ms 46356 KB Output is correct
54 Correct 949 ms 46400 KB Output is correct
55 Correct 0 ms 200 KB Output is correct
56 Correct 185 ms 45504 KB Output is correct
57 Correct 1054 ms 45680 KB Output is correct
58 Correct 409 ms 8264 KB Output is correct
59 Correct 989 ms 45760 KB Output is correct
60 Correct 458 ms 16324 KB Output is correct
61 Correct 1107 ms 45632 KB Output is correct
62 Correct 912 ms 45632 KB Output is correct
63 Correct 1006 ms 45632 KB Output is correct
64 Correct 1063 ms 45632 KB Output is correct
65 Correct 1022 ms 45632 KB Output is correct
66 Correct 1098 ms 46016 KB Output is correct
67 Correct 1075 ms 46436 KB Output is correct
68 Correct 1020 ms 46388 KB Output is correct
69 Correct 0 ms 200 KB Output is correct
70 Correct 0 ms 200 KB Output is correct
71 Correct 2 ms 328 KB Output is correct
72 Correct 1 ms 328 KB Output is correct
73 Correct 2 ms 328 KB Output is correct
74 Correct 2 ms 328 KB Output is correct
75 Correct 2 ms 328 KB Output is correct
76 Correct 0 ms 200 KB Output is correct
77 Correct 0 ms 328 KB Output is correct
78 Correct 2 ms 200 KB Output is correct
79 Correct 2 ms 328 KB Output is correct
80 Correct 2 ms 328 KB Output is correct
81 Correct 2 ms 328 KB Output is correct
82 Correct 2 ms 328 KB Output is correct
83 Correct 2 ms 328 KB Output is correct
84 Correct 0 ms 328 KB Output is correct
85 Correct 2 ms 328 KB Output is correct
86 Correct 17 ms 776 KB Output is correct
87 Correct 20 ms 712 KB Output is correct
88 Correct 20 ms 712 KB Output is correct
89 Correct 20 ms 712 KB Output is correct
90 Correct 23 ms 712 KB Output is correct
91 Correct 0 ms 328 KB Output is correct
92 Correct 1 ms 456 KB Output is correct
93 Correct 18 ms 712 KB Output is correct
94 Correct 16 ms 712 KB Output is correct
95 Correct 20 ms 712 KB Output is correct
96 Correct 16 ms 712 KB Output is correct
97 Correct 16 ms 712 KB Output is correct
98 Correct 0 ms 200 KB Output is correct
99 Correct 133 ms 45728 KB Output is correct
100 Correct 141 ms 45760 KB Output is correct
101 Correct 87 ms 45604 KB Output is correct
102 Correct 130 ms 45760 KB Output is correct
103 Correct 105 ms 46016 KB Output is correct
104 Correct 89 ms 46400 KB Output is correct
105 Correct 0 ms 200 KB Output is correct
106 Correct 71 ms 26516 KB Output is correct
107 Correct 131 ms 45804 KB Output is correct
108 Correct 99 ms 45632 KB Output is correct
109 Correct 120 ms 45684 KB Output is correct
110 Correct 105 ms 45968 KB Output is correct
111 Correct 90 ms 46356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 180 ms 36416 KB Output is correct
4 Correct 1123 ms 45588 KB Output is correct
5 Correct 960 ms 23108 KB Output is correct
6 Correct 1043 ms 45584 KB Output is correct
7 Correct 730 ms 31296 KB Output is correct
8 Correct 1038 ms 45624 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 0 ms 200 KB Output is correct
11 Correct 0 ms 200 KB Output is correct
12 Correct 0 ms 200 KB Output is correct
13 Correct 2 ms 200 KB Output is correct
14 Incorrect 2 ms 328 KB Output isn't correct
15 Halted 0 ms 0 KB -