Submission #763257

# Submission time Handle Problem Language Result Execution time Memory
763257 2023-06-22T07:18:36 Z cheat_when_I_was_young Xylophone (JOI18_xylophone) C++17
47 / 100
84 ms 20524 KB
#include "xylophone.h"
int q[5005][5005], a[5005];
void solve(int n) {
	for (int i = 1; i <= n-1; ++i) q[i][i+1] = q[i+1][i] = query(i, i+1);
	for (int i = 1; i <= n-2; ++i) q[i][i+2] = q[i+2][i] = query(i, i+2);
	int pos = 1;
	for (int i = 1<<12; i > 0; i >>= 1) {
		if (pos + i > n) continue;
		if (query(pos + i, n) == n - 1) pos += i;
	}
	a[pos] = 1;
	if (pos < n) a[pos+1] = q[pos][pos+1] + 1;
	if (pos > 1) a[pos-1] = q[pos][pos-1] + 1;
	for (int i = pos + 2; i <= n; ++i) {
		if (q[i-2][i-1] + q[i-1][i] == q[i-2][i]) {
			if (a[i-2] > a[i-1]) a[i] = a[i-1] - q[i-1][i];
			else a[i] = a[i-1] + q[i-1][i];
		} else {
			if (a[i-2] > a[i-1]) a[i] = a[i-1] + q[i-1][i];
			else a[i] = a[i-1] - q[i-1][i];
		}
	}
	for (int i = pos - 2; i >= 1; --i) {
		if (q[i+2][i+1] + q[i+1][i] == q[i+2][i]) {
			if (a[i+2] > a[i+1]) a[i] = a[i+1] - q[i+1][i];
			else a[i] = a[i+1] + q[i+1][i];
		} else {
			if (a[i+2] > a[i+1]) a[i] = a[i+1] + q[i+1][i];
			else a[i] = a[i+1] - q[i+1][i];
		}
	}
	for (int i = 1; i <= n; ++i) answer(i, a[i]);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 592 KB Output is correct
5 Correct 2 ms 592 KB Output is correct
6 Correct 2 ms 592 KB Output is correct
7 Correct 1 ms 592 KB Output is correct
8 Correct 2 ms 592 KB Output is correct
9 Correct 2 ms 592 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 2 ms 592 KB Output is correct
12 Correct 2 ms 592 KB Output is correct
13 Correct 2 ms 592 KB Output is correct
14 Correct 2 ms 592 KB Output is correct
15 Correct 2 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 592 KB Output is correct
5 Correct 2 ms 592 KB Output is correct
6 Correct 2 ms 592 KB Output is correct
7 Correct 1 ms 592 KB Output is correct
8 Correct 2 ms 592 KB Output is correct
9 Correct 2 ms 592 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 2 ms 592 KB Output is correct
12 Correct 2 ms 592 KB Output is correct
13 Correct 2 ms 592 KB Output is correct
14 Correct 2 ms 592 KB Output is correct
15 Correct 2 ms 592 KB Output is correct
16 Correct 3 ms 1104 KB Output is correct
17 Correct 7 ms 2128 KB Output is correct
18 Correct 13 ms 3600 KB Output is correct
19 Correct 20 ms 4312 KB Output is correct
20 Correct 19 ms 4264 KB Output is correct
21 Correct 18 ms 4312 KB Output is correct
22 Correct 18 ms 4304 KB Output is correct
23 Correct 18 ms 4304 KB Output is correct
24 Correct 14 ms 4328 KB Output is correct
25 Correct 18 ms 4252 KB Output is correct
26 Correct 20 ms 4328 KB Output is correct
27 Correct 19 ms 4268 KB Output is correct
28 Correct 18 ms 4344 KB Output is correct
29 Correct 14 ms 4268 KB Output is correct
30 Correct 12 ms 4304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 592 KB Output is correct
5 Correct 2 ms 592 KB Output is correct
6 Correct 2 ms 592 KB Output is correct
7 Correct 1 ms 592 KB Output is correct
8 Correct 2 ms 592 KB Output is correct
9 Correct 2 ms 592 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 2 ms 592 KB Output is correct
12 Correct 2 ms 592 KB Output is correct
13 Correct 2 ms 592 KB Output is correct
14 Correct 2 ms 592 KB Output is correct
15 Correct 2 ms 592 KB Output is correct
16 Correct 3 ms 1104 KB Output is correct
17 Correct 7 ms 2128 KB Output is correct
18 Correct 13 ms 3600 KB Output is correct
19 Correct 20 ms 4312 KB Output is correct
20 Correct 19 ms 4264 KB Output is correct
21 Correct 18 ms 4312 KB Output is correct
22 Correct 18 ms 4304 KB Output is correct
23 Correct 18 ms 4304 KB Output is correct
24 Correct 14 ms 4328 KB Output is correct
25 Correct 18 ms 4252 KB Output is correct
26 Correct 20 ms 4328 KB Output is correct
27 Correct 19 ms 4268 KB Output is correct
28 Correct 18 ms 4344 KB Output is correct
29 Correct 14 ms 4268 KB Output is correct
30 Correct 12 ms 4304 KB Output is correct
31 Correct 44 ms 9000 KB Output is correct
32 Correct 59 ms 12772 KB Output is correct
33 Correct 50 ms 17908 KB Output is correct
34 Incorrect 84 ms 20524 KB Wrong Answer [2]
35 Halted 0 ms 0 KB -