Submission #221828

# Submission time Handle Problem Language Result Execution time Memory
221828 2020-04-11T08:38:39 Z PeppaPig Xylophone (JOI18_xylophone) C++14
100 / 100
97 ms 640 KB
#include "xylophone.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 5e3+5;

int d1[N], d2[N], dir[N], ans[N];

void solve(int n) {
	for(int i = 1; i + 1 <= n; i++) d1[i] = query(i, i + 1);
	for(int i = 1; i + 2 <= n; i++) d2[i] = query(i, i + 2);

	dir[1] = 1;
	for(int i = 1; i + 2 <= n; i++) {
		if(d1[i] + d1[i + 1] == d2[i]) dir[i + 1] = dir[i];
		else dir[i + 1] = -dir[i];
	}
	int mn = 1, mx = 1;
	for(int i = 1; i + 1 <= n; i++) {
		ans[i + 1] = ans[i] + dir[i] * d1[i];
		if(ans[i + 1] < ans[mn]) mn = i + 1;
		if(ans[i + 1] > ans[mx]) mx = i + 1;
	}
	int k = ans[mn];
	for(int i = 1; i <= n; i++) {
		ans[i] -= k - 1;
		if(mn > mx) ans[i] = n - ans[i] + 1;
		answer(i, ans[i]);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 6 ms 256 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 256 KB Output is correct
7 Correct 7 ms 384 KB Output is correct
8 Correct 6 ms 256 KB Output is correct
9 Correct 6 ms 256 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 6 ms 256 KB Output is correct
12 Correct 6 ms 256 KB Output is correct
13 Correct 6 ms 256 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 6 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 6 ms 256 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 256 KB Output is correct
7 Correct 7 ms 384 KB Output is correct
8 Correct 6 ms 256 KB Output is correct
9 Correct 6 ms 256 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 6 ms 256 KB Output is correct
12 Correct 6 ms 256 KB Output is correct
13 Correct 6 ms 256 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 6 ms 512 KB Output is correct
16 Correct 8 ms 512 KB Output is correct
17 Correct 13 ms 384 KB Output is correct
18 Correct 16 ms 376 KB Output is correct
19 Correct 23 ms 384 KB Output is correct
20 Correct 24 ms 376 KB Output is correct
21 Correct 24 ms 384 KB Output is correct
22 Correct 23 ms 376 KB Output is correct
23 Correct 19 ms 384 KB Output is correct
24 Correct 22 ms 384 KB Output is correct
25 Correct 23 ms 384 KB Output is correct
26 Correct 24 ms 384 KB Output is correct
27 Correct 22 ms 384 KB Output is correct
28 Correct 21 ms 384 KB Output is correct
29 Correct 22 ms 384 KB Output is correct
30 Correct 18 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 6 ms 256 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 256 KB Output is correct
7 Correct 7 ms 384 KB Output is correct
8 Correct 6 ms 256 KB Output is correct
9 Correct 6 ms 256 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 6 ms 256 KB Output is correct
12 Correct 6 ms 256 KB Output is correct
13 Correct 6 ms 256 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 6 ms 512 KB Output is correct
16 Correct 8 ms 512 KB Output is correct
17 Correct 13 ms 384 KB Output is correct
18 Correct 16 ms 376 KB Output is correct
19 Correct 23 ms 384 KB Output is correct
20 Correct 24 ms 376 KB Output is correct
21 Correct 24 ms 384 KB Output is correct
22 Correct 23 ms 376 KB Output is correct
23 Correct 19 ms 384 KB Output is correct
24 Correct 22 ms 384 KB Output is correct
25 Correct 23 ms 384 KB Output is correct
26 Correct 24 ms 384 KB Output is correct
27 Correct 22 ms 384 KB Output is correct
28 Correct 21 ms 384 KB Output is correct
29 Correct 22 ms 384 KB Output is correct
30 Correct 18 ms 384 KB Output is correct
31 Correct 45 ms 384 KB Output is correct
32 Correct 56 ms 504 KB Output is correct
33 Correct 69 ms 384 KB Output is correct
34 Correct 87 ms 504 KB Output is correct
35 Correct 93 ms 384 KB Output is correct
36 Correct 95 ms 504 KB Output is correct
37 Correct 89 ms 376 KB Output is correct
38 Correct 93 ms 376 KB Output is correct
39 Correct 96 ms 376 KB Output is correct
40 Correct 87 ms 376 KB Output is correct
41 Correct 93 ms 384 KB Output is correct
42 Correct 94 ms 608 KB Output is correct
43 Correct 90 ms 376 KB Output is correct
44 Correct 97 ms 376 KB Output is correct
45 Correct 88 ms 504 KB Output is correct
46 Correct 52 ms 372 KB Output is correct
47 Correct 90 ms 376 KB Output is correct
48 Correct 86 ms 376 KB Output is correct
49 Correct 73 ms 552 KB Output is correct
50 Correct 88 ms 376 KB Output is correct
51 Correct 85 ms 376 KB Output is correct
52 Correct 87 ms 640 KB Output is correct
53 Correct 92 ms 376 KB Output is correct
54 Correct 83 ms 512 KB Output is correct
55 Correct 88 ms 384 KB Output is correct
56 Correct 90 ms 384 KB Output is correct
57 Correct 84 ms 376 KB Output is correct
58 Correct 85 ms 376 KB Output is correct
59 Correct 80 ms 504 KB Output is correct
60 Correct 91 ms 380 KB Output is correct