#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
#define REP(i, j, k) for (int i = j; i < k; i++)
void solve(int n) {
vector<int> a(n + 5, 0);
if (n == 1) {
answer(1, 1);
return;
}
a[2] = a[1] + query(1, 2);
int sign = a[2] > a[1] ? 1 : -1;
REP (i, 3, n + 1) {
int fi = query(i - 1, i), se = query(i - 2, i);
if (abs(a[i - 1] - a[i - 2]) + fi != se) {
sign = -sign;
}
a[i] = a[i - 1] + fi * sign;
}
int mn = 0;
REP (i, 1, n + 1) mn = min(mn, a[i]);
REP (i, 1, n + 1) a[i] -= mn;
REP (i, 1, n + 1) {
if (a[i] == 0) break;
if (a[i] == n - 1) {
REP (j, 1, n + 1) a[j] = n - a[j] - 1;
break;
}
}
REP (i, 1, n + 1) answer(i, a[i] + 1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 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 |
3 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 |
2 ms |
364 KB |
Output is correct |
12 |
Correct |
2 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
3 ms |
364 KB |
Output is correct |
15 |
Correct |
3 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 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 |
3 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 |
2 ms |
364 KB |
Output is correct |
12 |
Correct |
2 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
3 ms |
364 KB |
Output is correct |
15 |
Correct |
3 ms |
364 KB |
Output is correct |
16 |
Correct |
4 ms |
364 KB |
Output is correct |
17 |
Correct |
7 ms |
364 KB |
Output is correct |
18 |
Correct |
15 ms |
364 KB |
Output is correct |
19 |
Correct |
19 ms |
364 KB |
Output is correct |
20 |
Correct |
17 ms |
364 KB |
Output is correct |
21 |
Correct |
21 ms |
492 KB |
Output is correct |
22 |
Correct |
19 ms |
384 KB |
Output is correct |
23 |
Correct |
23 ms |
364 KB |
Output is correct |
24 |
Correct |
20 ms |
364 KB |
Output is correct |
25 |
Correct |
18 ms |
364 KB |
Output is correct |
26 |
Correct |
23 ms |
364 KB |
Output is correct |
27 |
Correct |
15 ms |
380 KB |
Output is correct |
28 |
Correct |
19 ms |
364 KB |
Output is correct |
29 |
Correct |
14 ms |
492 KB |
Output is correct |
30 |
Correct |
18 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 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 |
3 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 |
2 ms |
364 KB |
Output is correct |
12 |
Correct |
2 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
3 ms |
364 KB |
Output is correct |
15 |
Correct |
3 ms |
364 KB |
Output is correct |
16 |
Correct |
4 ms |
364 KB |
Output is correct |
17 |
Correct |
7 ms |
364 KB |
Output is correct |
18 |
Correct |
15 ms |
364 KB |
Output is correct |
19 |
Correct |
19 ms |
364 KB |
Output is correct |
20 |
Correct |
17 ms |
364 KB |
Output is correct |
21 |
Correct |
21 ms |
492 KB |
Output is correct |
22 |
Correct |
19 ms |
384 KB |
Output is correct |
23 |
Correct |
23 ms |
364 KB |
Output is correct |
24 |
Correct |
20 ms |
364 KB |
Output is correct |
25 |
Correct |
18 ms |
364 KB |
Output is correct |
26 |
Correct |
23 ms |
364 KB |
Output is correct |
27 |
Correct |
15 ms |
380 KB |
Output is correct |
28 |
Correct |
19 ms |
364 KB |
Output is correct |
29 |
Correct |
14 ms |
492 KB |
Output is correct |
30 |
Correct |
18 ms |
364 KB |
Output is correct |
31 |
Correct |
43 ms |
364 KB |
Output is correct |
32 |
Correct |
52 ms |
364 KB |
Output is correct |
33 |
Correct |
81 ms |
364 KB |
Output is correct |
34 |
Correct |
83 ms |
492 KB |
Output is correct |
35 |
Correct |
96 ms |
492 KB |
Output is correct |
36 |
Correct |
91 ms |
492 KB |
Output is correct |
37 |
Correct |
88 ms |
364 KB |
Output is correct |
38 |
Correct |
83 ms |
364 KB |
Output is correct |
39 |
Correct |
102 ms |
492 KB |
Output is correct |
40 |
Correct |
87 ms |
364 KB |
Output is correct |
41 |
Correct |
77 ms |
364 KB |
Output is correct |
42 |
Correct |
98 ms |
492 KB |
Output is correct |
43 |
Correct |
63 ms |
396 KB |
Output is correct |
44 |
Correct |
85 ms |
364 KB |
Output is correct |
45 |
Correct |
103 ms |
492 KB |
Output is correct |
46 |
Correct |
107 ms |
364 KB |
Output is correct |
47 |
Correct |
72 ms |
396 KB |
Output is correct |
48 |
Correct |
115 ms |
492 KB |
Output is correct |
49 |
Correct |
106 ms |
364 KB |
Output is correct |
50 |
Correct |
127 ms |
364 KB |
Output is correct |
51 |
Correct |
101 ms |
492 KB |
Output is correct |
52 |
Correct |
53 ms |
396 KB |
Output is correct |
53 |
Correct |
87 ms |
396 KB |
Output is correct |
54 |
Correct |
95 ms |
364 KB |
Output is correct |
55 |
Correct |
81 ms |
492 KB |
Output is correct |
56 |
Correct |
96 ms |
364 KB |
Output is correct |
57 |
Correct |
94 ms |
364 KB |
Output is correct |
58 |
Correct |
104 ms |
492 KB |
Output is correct |
59 |
Correct |
99 ms |
364 KB |
Output is correct |
60 |
Correct |
99 ms |
364 KB |
Output is correct |