#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#include "xylophone.h"
void solve(int n)
{
vector<int> a(n + 1);
vector<bool> ck(n + 1);
ck[1] = 1;
for (int i = 1; i < n; ++i)
a[i + 1] = query(i, i + 1);
for (int i = 1; i < n - 1; ++i)
{
int v = query(i, i + 2);
if (v == a[i + 2] + a[i + 1])
ck[i + 1] = ck[i];
else
ck[i + 1] = !ck[i];
}
int maxn(a[1]), minn(a[1]);
int mnp(1), mxp(1);
for (int i = 1; i < n; ++i)
{
a[i + 1] = a[i] + a[i + 1] * (ck[i] ? 1 : -1);
if (maxn < a[i + 1])
{
maxn = a[i + 1];
mxp = i + 1;
}
if (minn > a[i + 1])
{
minn = a[i + 1];
mnp = i + 1;
}
}
if (mnp < mxp)
{
for (int i = 1; i <= n; ++i)
answer(i, a[i] - minn + 1);
}
else
{
for (int i = 1; i <= n; ++i)
answer(i, -a[i] - (-maxn) + 1);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
268 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
3 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
2 ms |
364 KB |
Output is correct |
7 |
Correct |
2 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
2 ms |
364 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
372 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 |
3 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
268 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
3 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
2 ms |
364 KB |
Output is correct |
7 |
Correct |
2 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
2 ms |
364 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
372 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 |
3 ms |
364 KB |
Output is correct |
16 |
Correct |
5 ms |
364 KB |
Output is correct |
17 |
Correct |
7 ms |
364 KB |
Output is correct |
18 |
Correct |
9 ms |
380 KB |
Output is correct |
19 |
Correct |
14 ms |
364 KB |
Output is correct |
20 |
Correct |
27 ms |
364 KB |
Output is correct |
21 |
Correct |
16 ms |
364 KB |
Output is correct |
22 |
Correct |
22 ms |
364 KB |
Output is correct |
23 |
Correct |
14 ms |
364 KB |
Output is correct |
24 |
Correct |
16 ms |
492 KB |
Output is correct |
25 |
Correct |
25 ms |
364 KB |
Output is correct |
26 |
Correct |
26 ms |
492 KB |
Output is correct |
27 |
Correct |
20 ms |
364 KB |
Output is correct |
28 |
Correct |
19 ms |
364 KB |
Output is correct |
29 |
Correct |
18 ms |
364 KB |
Output is correct |
30 |
Correct |
18 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
268 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
3 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
2 ms |
364 KB |
Output is correct |
7 |
Correct |
2 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
2 ms |
364 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
372 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 |
3 ms |
364 KB |
Output is correct |
16 |
Correct |
5 ms |
364 KB |
Output is correct |
17 |
Correct |
7 ms |
364 KB |
Output is correct |
18 |
Correct |
9 ms |
380 KB |
Output is correct |
19 |
Correct |
14 ms |
364 KB |
Output is correct |
20 |
Correct |
27 ms |
364 KB |
Output is correct |
21 |
Correct |
16 ms |
364 KB |
Output is correct |
22 |
Correct |
22 ms |
364 KB |
Output is correct |
23 |
Correct |
14 ms |
364 KB |
Output is correct |
24 |
Correct |
16 ms |
492 KB |
Output is correct |
25 |
Correct |
25 ms |
364 KB |
Output is correct |
26 |
Correct |
26 ms |
492 KB |
Output is correct |
27 |
Correct |
20 ms |
364 KB |
Output is correct |
28 |
Correct |
19 ms |
364 KB |
Output is correct |
29 |
Correct |
18 ms |
364 KB |
Output is correct |
30 |
Correct |
18 ms |
364 KB |
Output is correct |
31 |
Correct |
43 ms |
364 KB |
Output is correct |
32 |
Correct |
73 ms |
384 KB |
Output is correct |
33 |
Correct |
75 ms |
492 KB |
Output is correct |
34 |
Correct |
89 ms |
364 KB |
Output is correct |
35 |
Correct |
89 ms |
364 KB |
Output is correct |
36 |
Correct |
106 ms |
364 KB |
Output is correct |
37 |
Correct |
85 ms |
364 KB |
Output is correct |
38 |
Correct |
100 ms |
364 KB |
Output is correct |
39 |
Correct |
97 ms |
492 KB |
Output is correct |
40 |
Correct |
95 ms |
492 KB |
Output is correct |
41 |
Correct |
118 ms |
396 KB |
Output is correct |
42 |
Correct |
90 ms |
492 KB |
Output is correct |
43 |
Correct |
116 ms |
396 KB |
Output is correct |
44 |
Correct |
92 ms |
364 KB |
Output is correct |
45 |
Correct |
125 ms |
364 KB |
Output is correct |
46 |
Correct |
104 ms |
396 KB |
Output is correct |
47 |
Correct |
102 ms |
364 KB |
Output is correct |
48 |
Correct |
89 ms |
364 KB |
Output is correct |
49 |
Correct |
89 ms |
364 KB |
Output is correct |
50 |
Correct |
82 ms |
364 KB |
Output is correct |
51 |
Correct |
116 ms |
396 KB |
Output is correct |
52 |
Correct |
124 ms |
364 KB |
Output is correct |
53 |
Correct |
54 ms |
396 KB |
Output is correct |
54 |
Correct |
67 ms |
364 KB |
Output is correct |
55 |
Correct |
94 ms |
492 KB |
Output is correct |
56 |
Correct |
97 ms |
492 KB |
Output is correct |
57 |
Correct |
101 ms |
364 KB |
Output is correct |
58 |
Correct |
124 ms |
364 KB |
Output is correct |
59 |
Correct |
91 ms |
492 KB |
Output is correct |
60 |
Correct |
124 ms |
492 KB |
Output is correct |