#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
int query(int,int);
void answer(int,int);
void solve(int N)
{
vector<int> V(N);
V[1] = query(1,2);
for(int i=2; i<N; i++)
{
int a = query(i,i+1);
int b = query(i-1,i+1);
if((abs(a-b) == abs(V[i-1]-V[i-2])) == (V[i-2] < V[i-1]))
V[i] = V[i-1] + a;
else
V[i] = V[i-1] - a;
}
auto it = minmax_element(V.begin(),V.end());
bool flip = it.fi < it.se;
int mi = *it.fi;
for(int& i : V) i = flip ? i+1-mi : N-i+mi;
for(int i=1; i<=N; i++)
answer(i,V[i-1]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
388 KB |
Output is correct |
4 |
Correct |
3 ms |
420 KB |
Output is correct |
5 |
Correct |
4 ms |
472 KB |
Output is correct |
6 |
Correct |
4 ms |
472 KB |
Output is correct |
7 |
Correct |
3 ms |
472 KB |
Output is correct |
8 |
Correct |
3 ms |
524 KB |
Output is correct |
9 |
Correct |
3 ms |
548 KB |
Output is correct |
10 |
Correct |
3 ms |
560 KB |
Output is correct |
11 |
Correct |
3 ms |
560 KB |
Output is correct |
12 |
Correct |
3 ms |
560 KB |
Output is correct |
13 |
Correct |
4 ms |
560 KB |
Output is correct |
14 |
Correct |
3 ms |
560 KB |
Output is correct |
15 |
Correct |
3 ms |
560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
388 KB |
Output is correct |
4 |
Correct |
3 ms |
420 KB |
Output is correct |
5 |
Correct |
4 ms |
472 KB |
Output is correct |
6 |
Correct |
4 ms |
472 KB |
Output is correct |
7 |
Correct |
3 ms |
472 KB |
Output is correct |
8 |
Correct |
3 ms |
524 KB |
Output is correct |
9 |
Correct |
3 ms |
548 KB |
Output is correct |
10 |
Correct |
3 ms |
560 KB |
Output is correct |
11 |
Correct |
3 ms |
560 KB |
Output is correct |
12 |
Correct |
3 ms |
560 KB |
Output is correct |
13 |
Correct |
4 ms |
560 KB |
Output is correct |
14 |
Correct |
3 ms |
560 KB |
Output is correct |
15 |
Correct |
3 ms |
560 KB |
Output is correct |
16 |
Correct |
6 ms |
560 KB |
Output is correct |
17 |
Correct |
10 ms |
560 KB |
Output is correct |
18 |
Correct |
16 ms |
560 KB |
Output is correct |
19 |
Correct |
19 ms |
560 KB |
Output is correct |
20 |
Correct |
22 ms |
560 KB |
Output is correct |
21 |
Correct |
20 ms |
560 KB |
Output is correct |
22 |
Correct |
21 ms |
560 KB |
Output is correct |
23 |
Correct |
18 ms |
560 KB |
Output is correct |
24 |
Correct |
23 ms |
560 KB |
Output is correct |
25 |
Correct |
22 ms |
560 KB |
Output is correct |
26 |
Correct |
16 ms |
560 KB |
Output is correct |
27 |
Correct |
12 ms |
572 KB |
Output is correct |
28 |
Correct |
23 ms |
572 KB |
Output is correct |
29 |
Correct |
25 ms |
572 KB |
Output is correct |
30 |
Correct |
14 ms |
572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
388 KB |
Output is correct |
4 |
Correct |
3 ms |
420 KB |
Output is correct |
5 |
Correct |
4 ms |
472 KB |
Output is correct |
6 |
Correct |
4 ms |
472 KB |
Output is correct |
7 |
Correct |
3 ms |
472 KB |
Output is correct |
8 |
Correct |
3 ms |
524 KB |
Output is correct |
9 |
Correct |
3 ms |
548 KB |
Output is correct |
10 |
Correct |
3 ms |
560 KB |
Output is correct |
11 |
Correct |
3 ms |
560 KB |
Output is correct |
12 |
Correct |
3 ms |
560 KB |
Output is correct |
13 |
Correct |
4 ms |
560 KB |
Output is correct |
14 |
Correct |
3 ms |
560 KB |
Output is correct |
15 |
Correct |
3 ms |
560 KB |
Output is correct |
16 |
Correct |
6 ms |
560 KB |
Output is correct |
17 |
Correct |
10 ms |
560 KB |
Output is correct |
18 |
Correct |
16 ms |
560 KB |
Output is correct |
19 |
Correct |
19 ms |
560 KB |
Output is correct |
20 |
Correct |
22 ms |
560 KB |
Output is correct |
21 |
Correct |
20 ms |
560 KB |
Output is correct |
22 |
Correct |
21 ms |
560 KB |
Output is correct |
23 |
Correct |
18 ms |
560 KB |
Output is correct |
24 |
Correct |
23 ms |
560 KB |
Output is correct |
25 |
Correct |
22 ms |
560 KB |
Output is correct |
26 |
Correct |
16 ms |
560 KB |
Output is correct |
27 |
Correct |
12 ms |
572 KB |
Output is correct |
28 |
Correct |
23 ms |
572 KB |
Output is correct |
29 |
Correct |
25 ms |
572 KB |
Output is correct |
30 |
Correct |
14 ms |
572 KB |
Output is correct |
31 |
Correct |
50 ms |
572 KB |
Output is correct |
32 |
Correct |
62 ms |
572 KB |
Output is correct |
33 |
Correct |
108 ms |
572 KB |
Output is correct |
34 |
Correct |
122 ms |
580 KB |
Output is correct |
35 |
Correct |
121 ms |
580 KB |
Output is correct |
36 |
Correct |
89 ms |
580 KB |
Output is correct |
37 |
Correct |
76 ms |
584 KB |
Output is correct |
38 |
Correct |
97 ms |
700 KB |
Output is correct |
39 |
Correct |
95 ms |
700 KB |
Output is correct |
40 |
Correct |
72 ms |
700 KB |
Output is correct |
41 |
Correct |
81 ms |
700 KB |
Output is correct |
42 |
Correct |
83 ms |
700 KB |
Output is correct |
43 |
Correct |
97 ms |
700 KB |
Output is correct |
44 |
Correct |
85 ms |
700 KB |
Output is correct |
45 |
Correct |
62 ms |
700 KB |
Output is correct |
46 |
Correct |
115 ms |
700 KB |
Output is correct |
47 |
Correct |
113 ms |
700 KB |
Output is correct |
48 |
Correct |
102 ms |
700 KB |
Output is correct |
49 |
Correct |
96 ms |
700 KB |
Output is correct |
50 |
Correct |
112 ms |
700 KB |
Output is correct |
51 |
Correct |
90 ms |
700 KB |
Output is correct |
52 |
Correct |
164 ms |
700 KB |
Output is correct |
53 |
Correct |
104 ms |
700 KB |
Output is correct |
54 |
Correct |
109 ms |
700 KB |
Output is correct |
55 |
Correct |
61 ms |
700 KB |
Output is correct |
56 |
Correct |
81 ms |
700 KB |
Output is correct |
57 |
Correct |
147 ms |
700 KB |
Output is correct |
58 |
Correct |
111 ms |
700 KB |
Output is correct |
59 |
Correct |
128 ms |
700 KB |
Output is correct |
60 |
Correct |
112 ms |
700 KB |
Output is correct |