#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
int a[5000];
void solve(int N) {
int n = N;
int pos1=n;
for (; pos1>=1; pos1--) {
int value = query(pos1, n);
if (value == n-1) break;
}
a[pos1] = 1;
a[pos1+1] = query(pos1, pos1+1) + 1;
for (int pt = pos1+2; pt<=n; pt++) {
int d1 = abs(a[pt-1] - a[pt-2]);
int d = query(pt-1, pt);
if (a[pt-2] < a[pt-1]) {
if (query(pt-2, pt) == d + d1) a[pt] = a[pt-1] + d;
else a[pt] = a[pt-1] - d;
} else {
if (query(pt-2, pt) == d + d1) a[pt] = a[pt-1] - d;
else a[pt] = a[pt-1] + d;
}
}
for (int pt = pos1-1; pt>=1; pt--) {
int d1 = abs(a[pt+1] - a[pt+2]);
int d = query(pt, pt+1);
if (a[pt+2] < a[pt+1]) {
if (query(pt, pt+2) == d + d1) a[pt] = a[pt+1] + d;
else a[pt] = a[pt+1] - d;
} else {
if (query(pt, pt+2) == d + d1) a[pt] = a[pt+1] - d;
else a[pt] = a[pt+1] + d;
}
}
// for (int i=1; i<=n; i++) cout << a[i] << ' ';
for(int i = 1; i <= N; i++) {
answer(i, a[i]);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
336 KB |
Output is correct |
4 |
Correct |
4 ms |
336 KB |
Output is correct |
5 |
Correct |
3 ms |
336 KB |
Output is correct |
6 |
Correct |
5 ms |
336 KB |
Output is correct |
7 |
Correct |
4 ms |
336 KB |
Output is correct |
8 |
Correct |
4 ms |
336 KB |
Output is correct |
9 |
Correct |
5 ms |
336 KB |
Output is correct |
10 |
Correct |
4 ms |
336 KB |
Output is correct |
11 |
Correct |
4 ms |
336 KB |
Output is correct |
12 |
Correct |
4 ms |
336 KB |
Output is correct |
13 |
Correct |
5 ms |
336 KB |
Output is correct |
14 |
Correct |
5 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 |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
336 KB |
Output is correct |
4 |
Correct |
4 ms |
336 KB |
Output is correct |
5 |
Correct |
3 ms |
336 KB |
Output is correct |
6 |
Correct |
5 ms |
336 KB |
Output is correct |
7 |
Correct |
4 ms |
336 KB |
Output is correct |
8 |
Correct |
4 ms |
336 KB |
Output is correct |
9 |
Correct |
5 ms |
336 KB |
Output is correct |
10 |
Correct |
4 ms |
336 KB |
Output is correct |
11 |
Correct |
4 ms |
336 KB |
Output is correct |
12 |
Correct |
4 ms |
336 KB |
Output is correct |
13 |
Correct |
5 ms |
336 KB |
Output is correct |
14 |
Correct |
5 ms |
336 KB |
Output is correct |
15 |
Correct |
4 ms |
336 KB |
Output is correct |
16 |
Correct |
10 ms |
336 KB |
Output is correct |
17 |
Correct |
14 ms |
336 KB |
Output is correct |
18 |
Correct |
38 ms |
432 KB |
Output is correct |
19 |
Correct |
42 ms |
336 KB |
Output is correct |
20 |
Correct |
36 ms |
584 KB |
Output is correct |
21 |
Correct |
39 ms |
432 KB |
Output is correct |
22 |
Correct |
50 ms |
584 KB |
Output is correct |
23 |
Correct |
45 ms |
432 KB |
Output is correct |
24 |
Correct |
26 ms |
336 KB |
Output is correct |
25 |
Correct |
53 ms |
584 KB |
Output is correct |
26 |
Correct |
39 ms |
432 KB |
Output is correct |
27 |
Correct |
37 ms |
440 KB |
Output is correct |
28 |
Correct |
43 ms |
336 KB |
Output is correct |
29 |
Correct |
61 ms |
432 KB |
Output is correct |
30 |
Correct |
37 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
336 KB |
Output is correct |
4 |
Correct |
4 ms |
336 KB |
Output is correct |
5 |
Correct |
3 ms |
336 KB |
Output is correct |
6 |
Correct |
5 ms |
336 KB |
Output is correct |
7 |
Correct |
4 ms |
336 KB |
Output is correct |
8 |
Correct |
4 ms |
336 KB |
Output is correct |
9 |
Correct |
5 ms |
336 KB |
Output is correct |
10 |
Correct |
4 ms |
336 KB |
Output is correct |
11 |
Correct |
4 ms |
336 KB |
Output is correct |
12 |
Correct |
4 ms |
336 KB |
Output is correct |
13 |
Correct |
5 ms |
336 KB |
Output is correct |
14 |
Correct |
5 ms |
336 KB |
Output is correct |
15 |
Correct |
4 ms |
336 KB |
Output is correct |
16 |
Correct |
10 ms |
336 KB |
Output is correct |
17 |
Correct |
14 ms |
336 KB |
Output is correct |
18 |
Correct |
38 ms |
432 KB |
Output is correct |
19 |
Correct |
42 ms |
336 KB |
Output is correct |
20 |
Correct |
36 ms |
584 KB |
Output is correct |
21 |
Correct |
39 ms |
432 KB |
Output is correct |
22 |
Correct |
50 ms |
584 KB |
Output is correct |
23 |
Correct |
45 ms |
432 KB |
Output is correct |
24 |
Correct |
26 ms |
336 KB |
Output is correct |
25 |
Correct |
53 ms |
584 KB |
Output is correct |
26 |
Correct |
39 ms |
432 KB |
Output is correct |
27 |
Correct |
37 ms |
440 KB |
Output is correct |
28 |
Correct |
43 ms |
336 KB |
Output is correct |
29 |
Correct |
61 ms |
432 KB |
Output is correct |
30 |
Correct |
37 ms |
336 KB |
Output is correct |
31 |
Correct |
106 ms |
584 KB |
Output is correct |
32 |
Correct |
144 ms |
444 KB |
Output is correct |
33 |
Incorrect |
182 ms |
588 KB |
Wrong Answer [2] |
34 |
Halted |
0 ms |
0 KB |
- |