#include <bits/stdc++.h>
#include "xylophone.h"
using namespace std;
const int MAX = 5010;
int a[MAX], d[MAX], t[MAX], dir[MAX];
void solve(int n) {
for(int i = 1; i + 1 <= n; ++i) {
d[i] = query(i, i + 1);
}
for(int i = 1; i + 2 <= n; ++i) {
t[i] = query(i, i + 2);
}
a[1] = 1;
dir[1] = 1;
for(int i = 1; i < n; ++i) {
if(d[i] + d[i + 1] == t[i]) {
dir[i + 1] = dir[i];
} else {
dir[i + 1] = -dir[i];
}
a[i + 1] = a[i] + dir[i] * d[i];
}
int mn = 1, mx = 1;
for(int i = 1; i <= n; ++i) {
if(a[i] < a[mn]) mn = i;
if(a[i] > a[mx]) mx = i;
}
int x = a[mn];
for(int i = 1; i <= n; ++i) {
a[i] = a[i] - x + 1;
}
if(mn > mx) {
for(int i = 1; i <= n; ++i) {
a[i] = n - a[i] + 1;
}
}
for(int i = 1; i <= n; ++i) {
answer(i, a[i]);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
312 KB |
Output is correct |
3 |
Correct |
2 ms |
316 KB |
Output is correct |
4 |
Correct |
4 ms |
248 KB |
Output is correct |
5 |
Correct |
4 ms |
248 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
4 ms |
328 KB |
Output is correct |
8 |
Correct |
4 ms |
248 KB |
Output is correct |
9 |
Correct |
3 ms |
248 KB |
Output is correct |
10 |
Correct |
4 ms |
248 KB |
Output is correct |
11 |
Correct |
4 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
316 KB |
Output is correct |
15 |
Correct |
4 ms |
248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
312 KB |
Output is correct |
3 |
Correct |
2 ms |
316 KB |
Output is correct |
4 |
Correct |
4 ms |
248 KB |
Output is correct |
5 |
Correct |
4 ms |
248 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
4 ms |
328 KB |
Output is correct |
8 |
Correct |
4 ms |
248 KB |
Output is correct |
9 |
Correct |
3 ms |
248 KB |
Output is correct |
10 |
Correct |
4 ms |
248 KB |
Output is correct |
11 |
Correct |
4 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
316 KB |
Output is correct |
15 |
Correct |
4 ms |
248 KB |
Output is correct |
16 |
Correct |
4 ms |
312 KB |
Output is correct |
17 |
Correct |
15 ms |
376 KB |
Output is correct |
18 |
Correct |
10 ms |
396 KB |
Output is correct |
19 |
Correct |
26 ms |
376 KB |
Output is correct |
20 |
Correct |
22 ms |
332 KB |
Output is correct |
21 |
Correct |
14 ms |
376 KB |
Output is correct |
22 |
Correct |
12 ms |
396 KB |
Output is correct |
23 |
Correct |
27 ms |
248 KB |
Output is correct |
24 |
Correct |
23 ms |
248 KB |
Output is correct |
25 |
Correct |
23 ms |
376 KB |
Output is correct |
26 |
Correct |
22 ms |
376 KB |
Output is correct |
27 |
Correct |
29 ms |
248 KB |
Output is correct |
28 |
Correct |
14 ms |
420 KB |
Output is correct |
29 |
Correct |
13 ms |
400 KB |
Output is correct |
30 |
Correct |
24 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
312 KB |
Output is correct |
3 |
Correct |
2 ms |
316 KB |
Output is correct |
4 |
Correct |
4 ms |
248 KB |
Output is correct |
5 |
Correct |
4 ms |
248 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
4 ms |
328 KB |
Output is correct |
8 |
Correct |
4 ms |
248 KB |
Output is correct |
9 |
Correct |
3 ms |
248 KB |
Output is correct |
10 |
Correct |
4 ms |
248 KB |
Output is correct |
11 |
Correct |
4 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
316 KB |
Output is correct |
15 |
Correct |
4 ms |
248 KB |
Output is correct |
16 |
Correct |
4 ms |
312 KB |
Output is correct |
17 |
Correct |
15 ms |
376 KB |
Output is correct |
18 |
Correct |
10 ms |
396 KB |
Output is correct |
19 |
Correct |
26 ms |
376 KB |
Output is correct |
20 |
Correct |
22 ms |
332 KB |
Output is correct |
21 |
Correct |
14 ms |
376 KB |
Output is correct |
22 |
Correct |
12 ms |
396 KB |
Output is correct |
23 |
Correct |
27 ms |
248 KB |
Output is correct |
24 |
Correct |
23 ms |
248 KB |
Output is correct |
25 |
Correct |
23 ms |
376 KB |
Output is correct |
26 |
Correct |
22 ms |
376 KB |
Output is correct |
27 |
Correct |
29 ms |
248 KB |
Output is correct |
28 |
Correct |
14 ms |
420 KB |
Output is correct |
29 |
Correct |
13 ms |
400 KB |
Output is correct |
30 |
Correct |
24 ms |
504 KB |
Output is correct |
31 |
Correct |
44 ms |
336 KB |
Output is correct |
32 |
Correct |
73 ms |
376 KB |
Output is correct |
33 |
Correct |
94 ms |
376 KB |
Output is correct |
34 |
Correct |
94 ms |
336 KB |
Output is correct |
35 |
Correct |
108 ms |
460 KB |
Output is correct |
36 |
Correct |
69 ms |
396 KB |
Output is correct |
37 |
Correct |
120 ms |
436 KB |
Output is correct |
38 |
Correct |
54 ms |
316 KB |
Output is correct |
39 |
Correct |
94 ms |
480 KB |
Output is correct |
40 |
Correct |
116 ms |
376 KB |
Output is correct |
41 |
Correct |
90 ms |
376 KB |
Output is correct |
42 |
Correct |
110 ms |
336 KB |
Output is correct |
43 |
Correct |
103 ms |
332 KB |
Output is correct |
44 |
Correct |
102 ms |
376 KB |
Output is correct |
45 |
Correct |
115 ms |
332 KB |
Output is correct |
46 |
Correct |
96 ms |
548 KB |
Output is correct |
47 |
Correct |
58 ms |
524 KB |
Output is correct |
48 |
Correct |
102 ms |
376 KB |
Output is correct |
49 |
Correct |
108 ms |
376 KB |
Output is correct |
50 |
Correct |
106 ms |
532 KB |
Output is correct |
51 |
Correct |
107 ms |
424 KB |
Output is correct |
52 |
Correct |
92 ms |
396 KB |
Output is correct |
53 |
Correct |
67 ms |
344 KB |
Output is correct |
54 |
Correct |
108 ms |
376 KB |
Output is correct |
55 |
Correct |
103 ms |
376 KB |
Output is correct |
56 |
Correct |
112 ms |
376 KB |
Output is correct |
57 |
Correct |
58 ms |
400 KB |
Output is correct |
58 |
Correct |
100 ms |
444 KB |
Output is correct |
59 |
Correct |
108 ms |
376 KB |
Output is correct |
60 |
Correct |
61 ms |
376 KB |
Output is correct |