#include <bits/stdc++.h>
#include "xylophone.h"
using namespace std;
int x[5005], y[5005], v[5005];
int calc(int a, int b, int x, int y){
if(abs(a-b) != y && x != y){
if(a > b)return b-x;
return b+x;
}else{
if(a > b)return b+x;
return b-x;
}
}
void solve(int n) {
v[1] = 1;
x[2] = query(1,2);
v[2] = 1+x[2];
for(int i = 3; i <= n; i++){
x[i] = query(i-1,i), y[i] = query(i-2,i);
v[i] = calc(v[i-2],v[i-1], x[i], y[i]);
}
int idmn = 1, idmx = 2;
for(int i = 2; i <= n; i++){
if(v[idmn] > v[i])idmn = i;
if(v[idmx] < v[i])idmx = i;
}
if(idmn > idmx){
v[2] = v[1] - x[2];
for(int i = 3; i <= n; i++)
v[i] = calc(v[i-2],v[i-1], x[i], y[i]);
idmn = 2, idmn = 1;
for(int i = 2; i <= n; i++){
if(v[idmn] > v[i])idmn = i;
if(v[idmx] < v[i])idmx = i;
}
}
for(int i = 1; i <= n; i++)
answer(i,v[i]-v[idmn]+1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
444 KB |
Output is correct |
4 |
Correct |
3 ms |
336 KB |
Output is correct |
5 |
Correct |
4 ms |
336 KB |
Output is correct |
6 |
Correct |
3 ms |
336 KB |
Output is correct |
7 |
Correct |
4 ms |
508 KB |
Output is correct |
8 |
Correct |
5 ms |
336 KB |
Output is correct |
9 |
Correct |
4 ms |
336 KB |
Output is correct |
10 |
Correct |
5 ms |
336 KB |
Output is correct |
11 |
Correct |
4 ms |
336 KB |
Output is correct |
12 |
Correct |
4 ms |
424 KB |
Output is correct |
13 |
Correct |
5 ms |
336 KB |
Output is correct |
14 |
Correct |
4 ms |
336 KB |
Output is correct |
15 |
Correct |
4 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
444 KB |
Output is correct |
4 |
Correct |
3 ms |
336 KB |
Output is correct |
5 |
Correct |
4 ms |
336 KB |
Output is correct |
6 |
Correct |
3 ms |
336 KB |
Output is correct |
7 |
Correct |
4 ms |
508 KB |
Output is correct |
8 |
Correct |
5 ms |
336 KB |
Output is correct |
9 |
Correct |
4 ms |
336 KB |
Output is correct |
10 |
Correct |
5 ms |
336 KB |
Output is correct |
11 |
Correct |
4 ms |
336 KB |
Output is correct |
12 |
Correct |
4 ms |
424 KB |
Output is correct |
13 |
Correct |
5 ms |
336 KB |
Output is correct |
14 |
Correct |
4 ms |
336 KB |
Output is correct |
15 |
Correct |
4 ms |
336 KB |
Output is correct |
16 |
Correct |
8 ms |
508 KB |
Output is correct |
17 |
Correct |
17 ms |
504 KB |
Output is correct |
18 |
Correct |
28 ms |
440 KB |
Output is correct |
19 |
Correct |
28 ms |
436 KB |
Output is correct |
20 |
Correct |
34 ms |
464 KB |
Output is correct |
21 |
Correct |
34 ms |
476 KB |
Output is correct |
22 |
Correct |
30 ms |
452 KB |
Output is correct |
23 |
Correct |
33 ms |
456 KB |
Output is correct |
24 |
Correct |
33 ms |
696 KB |
Output is correct |
25 |
Correct |
31 ms |
452 KB |
Output is correct |
26 |
Correct |
34 ms |
592 KB |
Output is correct |
27 |
Correct |
32 ms |
712 KB |
Output is correct |
28 |
Correct |
32 ms |
452 KB |
Output is correct |
29 |
Correct |
37 ms |
704 KB |
Output is correct |
30 |
Correct |
33 ms |
440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
444 KB |
Output is correct |
4 |
Correct |
3 ms |
336 KB |
Output is correct |
5 |
Correct |
4 ms |
336 KB |
Output is correct |
6 |
Correct |
3 ms |
336 KB |
Output is correct |
7 |
Correct |
4 ms |
508 KB |
Output is correct |
8 |
Correct |
5 ms |
336 KB |
Output is correct |
9 |
Correct |
4 ms |
336 KB |
Output is correct |
10 |
Correct |
5 ms |
336 KB |
Output is correct |
11 |
Correct |
4 ms |
336 KB |
Output is correct |
12 |
Correct |
4 ms |
424 KB |
Output is correct |
13 |
Correct |
5 ms |
336 KB |
Output is correct |
14 |
Correct |
4 ms |
336 KB |
Output is correct |
15 |
Correct |
4 ms |
336 KB |
Output is correct |
16 |
Correct |
8 ms |
508 KB |
Output is correct |
17 |
Correct |
17 ms |
504 KB |
Output is correct |
18 |
Correct |
28 ms |
440 KB |
Output is correct |
19 |
Correct |
28 ms |
436 KB |
Output is correct |
20 |
Correct |
34 ms |
464 KB |
Output is correct |
21 |
Correct |
34 ms |
476 KB |
Output is correct |
22 |
Correct |
30 ms |
452 KB |
Output is correct |
23 |
Correct |
33 ms |
456 KB |
Output is correct |
24 |
Correct |
33 ms |
696 KB |
Output is correct |
25 |
Correct |
31 ms |
452 KB |
Output is correct |
26 |
Correct |
34 ms |
592 KB |
Output is correct |
27 |
Correct |
32 ms |
712 KB |
Output is correct |
28 |
Correct |
32 ms |
452 KB |
Output is correct |
29 |
Correct |
37 ms |
704 KB |
Output is correct |
30 |
Correct |
33 ms |
440 KB |
Output is correct |
31 |
Correct |
67 ms |
456 KB |
Output is correct |
32 |
Correct |
95 ms |
704 KB |
Output is correct |
33 |
Correct |
147 ms |
728 KB |
Output is correct |
34 |
Correct |
173 ms |
484 KB |
Output is correct |
35 |
Correct |
176 ms |
840 KB |
Output is correct |
36 |
Correct |
151 ms |
716 KB |
Output is correct |
37 |
Correct |
155 ms |
704 KB |
Output is correct |
38 |
Correct |
167 ms |
716 KB |
Output is correct |
39 |
Correct |
167 ms |
700 KB |
Output is correct |
40 |
Correct |
165 ms |
716 KB |
Output is correct |
41 |
Correct |
147 ms |
700 KB |
Output is correct |
42 |
Correct |
167 ms |
984 KB |
Output is correct |
43 |
Correct |
162 ms |
968 KB |
Output is correct |
44 |
Correct |
162 ms |
984 KB |
Output is correct |
45 |
Correct |
154 ms |
716 KB |
Output is correct |
46 |
Correct |
160 ms |
728 KB |
Output is correct |
47 |
Correct |
158 ms |
736 KB |
Output is correct |
48 |
Correct |
176 ms |
584 KB |
Output is correct |
49 |
Correct |
175 ms |
736 KB |
Output is correct |
50 |
Correct |
183 ms |
744 KB |
Output is correct |
51 |
Correct |
157 ms |
700 KB |
Output is correct |
52 |
Correct |
182 ms |
972 KB |
Output is correct |
53 |
Correct |
178 ms |
728 KB |
Output is correct |
54 |
Correct |
157 ms |
716 KB |
Output is correct |
55 |
Correct |
151 ms |
696 KB |
Output is correct |
56 |
Correct |
154 ms |
964 KB |
Output is correct |
57 |
Correct |
160 ms |
952 KB |
Output is correct |
58 |
Correct |
150 ms |
736 KB |
Output is correct |
59 |
Correct |
157 ms |
988 KB |
Output is correct |
60 |
Correct |
149 ms |
988 KB |
Output is correct |