#include "xylophone.h"
#include<bits/stdc++.h>
using namespace std;
int rv1[5005],rv2[5005];
int sign[5005];
int a[5005];
void solve(int N) {
for(int i=1; i<=N-1; i++) {
rv1[i] = query(i, i+1);
}
for(int i=1; i<=N-2; i++) {
rv2[i] = query(i, i+2);
}
for(sign[1] = 0; sign[1] <= 1; sign[1]++) {
for(int i=1; i<=N-2; i++) {
if(rv2[i] == rv1[i+1] + rv1[i]) {
sign[i+1] = sign[i];
} else {
sign[i+1] = 1 - sign[i];
}
}
a[1] = 0;
int mn = 0;
for(int i=2; i<=N; i++) {
if(sign[i-1] == 0) a[i] = a[i-1] + rv1[i-1];
else a[i] = a[i-1] - rv1[i-1];
mn = min(mn, a[i]);
}
int pos1, posN;
for(int i=1; i<=N; i++) {
a[i] += (1-mn);
if(a[i] == 1) pos1 = i;
else if(a[i] == N) posN = i;
}
if(pos1 < posN) {
for(int i=1; i<=N; i++) {
answer(i, a[i]);
}
return;
}
}
}
Compilation message
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:38:3: warning: 'posN' may be used uninitialized in this function [-Wmaybe-uninitialized]
38 | if(pos1 < posN) {
| ^~
xylophone.cpp:38:3: warning: 'pos1' may be used uninitialized in this function [-Wmaybe-uninitialized]
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
364 KB |
Output is correct |
7 |
Correct |
2 ms |
364 KB |
Output is correct |
8 |
Correct |
2 ms |
364 KB |
Output is correct |
9 |
Correct |
2 ms |
364 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
3 ms |
364 KB |
Output is correct |
12 |
Correct |
2 ms |
364 KB |
Output is correct |
13 |
Correct |
3 ms |
364 KB |
Output is correct |
14 |
Correct |
3 ms |
364 KB |
Output is correct |
15 |
Correct |
2 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
364 KB |
Output is correct |
7 |
Correct |
2 ms |
364 KB |
Output is correct |
8 |
Correct |
2 ms |
364 KB |
Output is correct |
9 |
Correct |
2 ms |
364 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
3 ms |
364 KB |
Output is correct |
12 |
Correct |
2 ms |
364 KB |
Output is correct |
13 |
Correct |
3 ms |
364 KB |
Output is correct |
14 |
Correct |
3 ms |
364 KB |
Output is correct |
15 |
Correct |
2 ms |
364 KB |
Output is correct |
16 |
Correct |
4 ms |
364 KB |
Output is correct |
17 |
Correct |
16 ms |
364 KB |
Output is correct |
18 |
Correct |
12 ms |
364 KB |
Output is correct |
19 |
Correct |
17 ms |
492 KB |
Output is correct |
20 |
Correct |
12 ms |
384 KB |
Output is correct |
21 |
Correct |
23 ms |
364 KB |
Output is correct |
22 |
Correct |
16 ms |
364 KB |
Output is correct |
23 |
Correct |
16 ms |
364 KB |
Output is correct |
24 |
Correct |
15 ms |
492 KB |
Output is correct |
25 |
Correct |
16 ms |
364 KB |
Output is correct |
26 |
Correct |
19 ms |
364 KB |
Output is correct |
27 |
Correct |
18 ms |
364 KB |
Output is correct |
28 |
Correct |
23 ms |
364 KB |
Output is correct |
29 |
Correct |
25 ms |
364 KB |
Output is correct |
30 |
Correct |
22 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
364 KB |
Output is correct |
7 |
Correct |
2 ms |
364 KB |
Output is correct |
8 |
Correct |
2 ms |
364 KB |
Output is correct |
9 |
Correct |
2 ms |
364 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
3 ms |
364 KB |
Output is correct |
12 |
Correct |
2 ms |
364 KB |
Output is correct |
13 |
Correct |
3 ms |
364 KB |
Output is correct |
14 |
Correct |
3 ms |
364 KB |
Output is correct |
15 |
Correct |
2 ms |
364 KB |
Output is correct |
16 |
Correct |
4 ms |
364 KB |
Output is correct |
17 |
Correct |
16 ms |
364 KB |
Output is correct |
18 |
Correct |
12 ms |
364 KB |
Output is correct |
19 |
Correct |
17 ms |
492 KB |
Output is correct |
20 |
Correct |
12 ms |
384 KB |
Output is correct |
21 |
Correct |
23 ms |
364 KB |
Output is correct |
22 |
Correct |
16 ms |
364 KB |
Output is correct |
23 |
Correct |
16 ms |
364 KB |
Output is correct |
24 |
Correct |
15 ms |
492 KB |
Output is correct |
25 |
Correct |
16 ms |
364 KB |
Output is correct |
26 |
Correct |
19 ms |
364 KB |
Output is correct |
27 |
Correct |
18 ms |
364 KB |
Output is correct |
28 |
Correct |
23 ms |
364 KB |
Output is correct |
29 |
Correct |
25 ms |
364 KB |
Output is correct |
30 |
Correct |
22 ms |
364 KB |
Output is correct |
31 |
Correct |
36 ms |
364 KB |
Output is correct |
32 |
Correct |
53 ms |
392 KB |
Output is correct |
33 |
Correct |
100 ms |
512 KB |
Output is correct |
34 |
Correct |
101 ms |
516 KB |
Output is correct |
35 |
Correct |
96 ms |
492 KB |
Output is correct |
36 |
Correct |
96 ms |
364 KB |
Output is correct |
37 |
Correct |
107 ms |
492 KB |
Output is correct |
38 |
Correct |
90 ms |
536 KB |
Output is correct |
39 |
Correct |
95 ms |
364 KB |
Output is correct |
40 |
Correct |
54 ms |
640 KB |
Output is correct |
41 |
Correct |
91 ms |
492 KB |
Output is correct |
42 |
Correct |
85 ms |
492 KB |
Output is correct |
43 |
Correct |
91 ms |
364 KB |
Output is correct |
44 |
Correct |
82 ms |
528 KB |
Output is correct |
45 |
Correct |
91 ms |
620 KB |
Output is correct |
46 |
Correct |
90 ms |
364 KB |
Output is correct |
47 |
Correct |
86 ms |
492 KB |
Output is correct |
48 |
Correct |
96 ms |
620 KB |
Output is correct |
49 |
Correct |
95 ms |
364 KB |
Output is correct |
50 |
Correct |
100 ms |
364 KB |
Output is correct |
51 |
Correct |
76 ms |
620 KB |
Output is correct |
52 |
Correct |
86 ms |
364 KB |
Output is correct |
53 |
Correct |
103 ms |
496 KB |
Output is correct |
54 |
Correct |
97 ms |
364 KB |
Output is correct |
55 |
Correct |
76 ms |
364 KB |
Output is correct |
56 |
Correct |
83 ms |
628 KB |
Output is correct |
57 |
Correct |
74 ms |
364 KB |
Output is correct |
58 |
Correct |
88 ms |
364 KB |
Output is correct |
59 |
Correct |
80 ms |
492 KB |
Output is correct |
60 |
Correct |
104 ms |
512 KB |
Output is correct |