#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
const int MAX = 5005;
int A[MAX];
void solve(int N) {
A[2] = query(1, 2);
for (int i = 3; i <= N; ++i) {
int d1 = query(i - 1, i);
int d2 = query(i - 2, i);
if (abs(A[i - 1] - A[i - 2]) + d1 == d2) {
if (A[i - 2] < A[i - 1]) A[i] = A[i - 1] + d1;
else A[i] = A[i - 1] - d1;
}
else {
if (A[i - 2] < A[i - 1]) A[i] = A[i - 1] - d1;
else A[i] = A[i - 1] + d1;
}
}
int off = *min_element(A + 1, A + N + 1);
for (int i = 1; i <= N; ++i) A[i] = A[i] - off + 1;
if (min_element(A + 1, A + N + 1) - max_element(A + 1, A + N + 1) > 0) {
for (int i = 1; i <= N; ++i) A[i] = N + 1 - A[i];
}
for(int i = 1; i <= N; i++) answer(i, A[i]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
596 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
596 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
2 ms |
596 KB |
Output is correct |
17 |
Correct |
4 ms |
440 KB |
Output is correct |
18 |
Correct |
8 ms |
444 KB |
Output is correct |
19 |
Correct |
14 ms |
432 KB |
Output is correct |
20 |
Correct |
9 ms |
436 KB |
Output is correct |
21 |
Correct |
10 ms |
444 KB |
Output is correct |
22 |
Correct |
10 ms |
432 KB |
Output is correct |
23 |
Correct |
7 ms |
436 KB |
Output is correct |
24 |
Correct |
8 ms |
436 KB |
Output is correct |
25 |
Correct |
8 ms |
436 KB |
Output is correct |
26 |
Correct |
12 ms |
444 KB |
Output is correct |
27 |
Correct |
11 ms |
436 KB |
Output is correct |
28 |
Correct |
7 ms |
696 KB |
Output is correct |
29 |
Correct |
10 ms |
440 KB |
Output is correct |
30 |
Correct |
9 ms |
444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
596 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
2 ms |
596 KB |
Output is correct |
17 |
Correct |
4 ms |
440 KB |
Output is correct |
18 |
Correct |
8 ms |
444 KB |
Output is correct |
19 |
Correct |
14 ms |
432 KB |
Output is correct |
20 |
Correct |
9 ms |
436 KB |
Output is correct |
21 |
Correct |
10 ms |
444 KB |
Output is correct |
22 |
Correct |
10 ms |
432 KB |
Output is correct |
23 |
Correct |
7 ms |
436 KB |
Output is correct |
24 |
Correct |
8 ms |
436 KB |
Output is correct |
25 |
Correct |
8 ms |
436 KB |
Output is correct |
26 |
Correct |
12 ms |
444 KB |
Output is correct |
27 |
Correct |
11 ms |
436 KB |
Output is correct |
28 |
Correct |
7 ms |
696 KB |
Output is correct |
29 |
Correct |
10 ms |
440 KB |
Output is correct |
30 |
Correct |
9 ms |
444 KB |
Output is correct |
31 |
Correct |
18 ms |
700 KB |
Output is correct |
32 |
Correct |
30 ms |
432 KB |
Output is correct |
33 |
Correct |
45 ms |
688 KB |
Output is correct |
34 |
Correct |
51 ms |
676 KB |
Output is correct |
35 |
Correct |
52 ms |
692 KB |
Output is correct |
36 |
Correct |
51 ms |
680 KB |
Output is correct |
37 |
Correct |
49 ms |
680 KB |
Output is correct |
38 |
Correct |
41 ms |
924 KB |
Output is correct |
39 |
Correct |
47 ms |
684 KB |
Output is correct |
40 |
Correct |
48 ms |
696 KB |
Output is correct |
41 |
Correct |
38 ms |
952 KB |
Output is correct |
42 |
Correct |
52 ms |
692 KB |
Output is correct |
43 |
Correct |
52 ms |
700 KB |
Output is correct |
44 |
Correct |
55 ms |
680 KB |
Output is correct |
45 |
Correct |
54 ms |
448 KB |
Output is correct |
46 |
Correct |
47 ms |
696 KB |
Output is correct |
47 |
Correct |
67 ms |
696 KB |
Output is correct |
48 |
Correct |
50 ms |
1200 KB |
Output is correct |
49 |
Correct |
49 ms |
696 KB |
Output is correct |
50 |
Correct |
52 ms |
700 KB |
Output is correct |
51 |
Correct |
50 ms |
672 KB |
Output is correct |
52 |
Correct |
62 ms |
696 KB |
Output is correct |
53 |
Correct |
44 ms |
944 KB |
Output is correct |
54 |
Correct |
55 ms |
688 KB |
Output is correct |
55 |
Correct |
50 ms |
1180 KB |
Output is correct |
56 |
Correct |
51 ms |
436 KB |
Output is correct |
57 |
Correct |
57 ms |
692 KB |
Output is correct |
58 |
Correct |
59 ms |
952 KB |
Output is correct |
59 |
Correct |
63 ms |
680 KB |
Output is correct |
60 |
Correct |
43 ms |
436 KB |
Output is correct |