#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
int n, A[5005];
int getNum(int a1, int a2, int a, int b) {
if(a > b) {
if(a2 - a1 == a - b) return a + a1;
return a - a1;
} else {
if(a2 - a1 == b - a) return a - a1;
return a + a1;
}
}
void solve(int N) {
n = N;
A[1] = 0, A[2] = query(1, 2);
for(int i = 3; i <= n; ++i) A[i] = getNum(query(i-1, i), query(i-2, i), A[i-1], A[i-2]);
int mn = *min_element(A+1, A+n+1);
int p1, pn;
for_each(A+1, A+n+1, [&](int &x) { x = x - mn + 1; });
for(int i = 1; i <= n; ++i) {
if(A[i] == 1) p1 = i;
if(A[i] == n) pn = i;
}
if(p1 > pn) for_each(A+1, A+n+1, [&](int &x) { x = n - x + 1; });
for(int i = 1; i <= n; ++i) answer(i, A[i]);
}
Compilation message
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:28:2: warning: 'p1' may be used uninitialized in this function [-Wmaybe-uninitialized]
if(p1 > pn) for_each(A+1, A+n+1, [&](int &x) { x = n - x + 1; });
^~
xylophone.cpp:28:2: warning: 'pn' may be used uninitialized in this function [-Wmaybe-uninitialized]
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
440 KB |
Output is correct |
3 |
Correct |
2 ms |
440 KB |
Output is correct |
4 |
Correct |
4 ms |
448 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
4 ms |
512 KB |
Output is correct |
9 |
Correct |
4 ms |
512 KB |
Output is correct |
10 |
Correct |
4 ms |
532 KB |
Output is correct |
11 |
Correct |
4 ms |
532 KB |
Output is correct |
12 |
Correct |
3 ms |
532 KB |
Output is correct |
13 |
Correct |
3 ms |
532 KB |
Output is correct |
14 |
Correct |
4 ms |
532 KB |
Output is correct |
15 |
Correct |
4 ms |
532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
440 KB |
Output is correct |
3 |
Correct |
2 ms |
440 KB |
Output is correct |
4 |
Correct |
4 ms |
448 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
4 ms |
512 KB |
Output is correct |
9 |
Correct |
4 ms |
512 KB |
Output is correct |
10 |
Correct |
4 ms |
532 KB |
Output is correct |
11 |
Correct |
4 ms |
532 KB |
Output is correct |
12 |
Correct |
3 ms |
532 KB |
Output is correct |
13 |
Correct |
3 ms |
532 KB |
Output is correct |
14 |
Correct |
4 ms |
532 KB |
Output is correct |
15 |
Correct |
4 ms |
532 KB |
Output is correct |
16 |
Correct |
7 ms |
532 KB |
Output is correct |
17 |
Correct |
18 ms |
532 KB |
Output is correct |
18 |
Correct |
26 ms |
564 KB |
Output is correct |
19 |
Correct |
14 ms |
572 KB |
Output is correct |
20 |
Correct |
30 ms |
572 KB |
Output is correct |
21 |
Correct |
30 ms |
572 KB |
Output is correct |
22 |
Correct |
13 ms |
572 KB |
Output is correct |
23 |
Correct |
33 ms |
572 KB |
Output is correct |
24 |
Correct |
30 ms |
576 KB |
Output is correct |
25 |
Correct |
34 ms |
576 KB |
Output is correct |
26 |
Correct |
27 ms |
576 KB |
Output is correct |
27 |
Correct |
30 ms |
576 KB |
Output is correct |
28 |
Correct |
16 ms |
576 KB |
Output is correct |
29 |
Correct |
25 ms |
576 KB |
Output is correct |
30 |
Correct |
34 ms |
576 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
440 KB |
Output is correct |
3 |
Correct |
2 ms |
440 KB |
Output is correct |
4 |
Correct |
4 ms |
448 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
4 ms |
512 KB |
Output is correct |
8 |
Correct |
4 ms |
512 KB |
Output is correct |
9 |
Correct |
4 ms |
512 KB |
Output is correct |
10 |
Correct |
4 ms |
532 KB |
Output is correct |
11 |
Correct |
4 ms |
532 KB |
Output is correct |
12 |
Correct |
3 ms |
532 KB |
Output is correct |
13 |
Correct |
3 ms |
532 KB |
Output is correct |
14 |
Correct |
4 ms |
532 KB |
Output is correct |
15 |
Correct |
4 ms |
532 KB |
Output is correct |
16 |
Correct |
7 ms |
532 KB |
Output is correct |
17 |
Correct |
18 ms |
532 KB |
Output is correct |
18 |
Correct |
26 ms |
564 KB |
Output is correct |
19 |
Correct |
14 ms |
572 KB |
Output is correct |
20 |
Correct |
30 ms |
572 KB |
Output is correct |
21 |
Correct |
30 ms |
572 KB |
Output is correct |
22 |
Correct |
13 ms |
572 KB |
Output is correct |
23 |
Correct |
33 ms |
572 KB |
Output is correct |
24 |
Correct |
30 ms |
576 KB |
Output is correct |
25 |
Correct |
34 ms |
576 KB |
Output is correct |
26 |
Correct |
27 ms |
576 KB |
Output is correct |
27 |
Correct |
30 ms |
576 KB |
Output is correct |
28 |
Correct |
16 ms |
576 KB |
Output is correct |
29 |
Correct |
25 ms |
576 KB |
Output is correct |
30 |
Correct |
34 ms |
576 KB |
Output is correct |
31 |
Correct |
62 ms |
576 KB |
Output is correct |
32 |
Correct |
45 ms |
576 KB |
Output is correct |
33 |
Correct |
134 ms |
584 KB |
Output is correct |
34 |
Correct |
121 ms |
584 KB |
Output is correct |
35 |
Correct |
116 ms |
704 KB |
Output is correct |
36 |
Correct |
81 ms |
704 KB |
Output is correct |
37 |
Correct |
144 ms |
704 KB |
Output is correct |
38 |
Correct |
87 ms |
704 KB |
Output is correct |
39 |
Correct |
66 ms |
704 KB |
Output is correct |
40 |
Correct |
53 ms |
704 KB |
Output is correct |
41 |
Correct |
165 ms |
704 KB |
Output is correct |
42 |
Correct |
98 ms |
704 KB |
Output is correct |
43 |
Correct |
131 ms |
704 KB |
Output is correct |
44 |
Correct |
160 ms |
704 KB |
Output is correct |
45 |
Correct |
142 ms |
704 KB |
Output is correct |
46 |
Correct |
50 ms |
704 KB |
Output is correct |
47 |
Correct |
121 ms |
704 KB |
Output is correct |
48 |
Correct |
71 ms |
704 KB |
Output is correct |
49 |
Correct |
158 ms |
704 KB |
Output is correct |
50 |
Correct |
52 ms |
704 KB |
Output is correct |
51 |
Correct |
148 ms |
704 KB |
Output is correct |
52 |
Correct |
158 ms |
704 KB |
Output is correct |
53 |
Correct |
106 ms |
704 KB |
Output is correct |
54 |
Correct |
102 ms |
704 KB |
Output is correct |
55 |
Correct |
117 ms |
820 KB |
Output is correct |
56 |
Correct |
145 ms |
820 KB |
Output is correct |
57 |
Correct |
133 ms |
820 KB |
Output is correct |
58 |
Correct |
61 ms |
820 KB |
Output is correct |
59 |
Correct |
92 ms |
820 KB |
Output is correct |
60 |
Correct |
139 ms |
820 KB |
Output is correct |