#include "xylophone.h"
#include<bits/stdc++.h>
using namespace std;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
const int LIM=5e5+7;
int A[LIM], B[LIM], rodzaj[LIM], T[LIM];
void solve(int n) {
rep(i, n-1) A[i]=query(i+1, i+2);
rep(i, n-2) B[i]=query(i+1, i+3);
rep(i, n-2) if(A[i]+A[i+1]!=B[i]) rodzaj[i+1]=rodzaj[i]^1; else rodzaj[i+1]=rodzaj[i];
rep(i, n-1) {
if(rodzaj[i]) T[i+1]=T[i]+A[i];
else T[i+1]=T[i]-A[i];
}
int mi=LIM, ma=-LIM, ind1=-1, ind2=-1;
rep(i, n) {
if(T[i]<mi) {
mi=T[i];
ind1=i;
}
if(T[i]>ma) {
ma=T[i];
ind2=i;
}
}
if(ind1<ind2) {
rep(i, n) answer(i+1, T[i]-mi+1);
return;
}
rep(i, n-1) {
if(rodzaj[i]) T[i+1]=T[i]-A[i];
else T[i+1]=T[i]+A[i];
}
mi=LIM;
rep(i, n) mi=min(mi, T[i]);
rep(i, n) answer(i+1, T[i]-mi+1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
2 ms |
292 KB |
Output is correct |
5 |
Correct |
2 ms |
320 KB |
Output is correct |
6 |
Correct |
2 ms |
200 KB |
Output is correct |
7 |
Correct |
2 ms |
200 KB |
Output is correct |
8 |
Correct |
2 ms |
200 KB |
Output is correct |
9 |
Correct |
2 ms |
292 KB |
Output is correct |
10 |
Correct |
2 ms |
200 KB |
Output is correct |
11 |
Correct |
2 ms |
200 KB |
Output is correct |
12 |
Correct |
2 ms |
200 KB |
Output is correct |
13 |
Correct |
1 ms |
296 KB |
Output is correct |
14 |
Correct |
2 ms |
200 KB |
Output is correct |
15 |
Correct |
2 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
2 ms |
292 KB |
Output is correct |
5 |
Correct |
2 ms |
320 KB |
Output is correct |
6 |
Correct |
2 ms |
200 KB |
Output is correct |
7 |
Correct |
2 ms |
200 KB |
Output is correct |
8 |
Correct |
2 ms |
200 KB |
Output is correct |
9 |
Correct |
2 ms |
292 KB |
Output is correct |
10 |
Correct |
2 ms |
200 KB |
Output is correct |
11 |
Correct |
2 ms |
200 KB |
Output is correct |
12 |
Correct |
2 ms |
200 KB |
Output is correct |
13 |
Correct |
1 ms |
296 KB |
Output is correct |
14 |
Correct |
2 ms |
200 KB |
Output is correct |
15 |
Correct |
2 ms |
200 KB |
Output is correct |
16 |
Correct |
4 ms |
296 KB |
Output is correct |
17 |
Correct |
6 ms |
328 KB |
Output is correct |
18 |
Correct |
17 ms |
300 KB |
Output is correct |
19 |
Correct |
20 ms |
308 KB |
Output is correct |
20 |
Correct |
8 ms |
324 KB |
Output is correct |
21 |
Correct |
19 ms |
312 KB |
Output is correct |
22 |
Correct |
14 ms |
316 KB |
Output is correct |
23 |
Correct |
14 ms |
308 KB |
Output is correct |
24 |
Correct |
15 ms |
324 KB |
Output is correct |
25 |
Correct |
17 ms |
288 KB |
Output is correct |
26 |
Correct |
17 ms |
312 KB |
Output is correct |
27 |
Correct |
17 ms |
328 KB |
Output is correct |
28 |
Correct |
13 ms |
308 KB |
Output is correct |
29 |
Correct |
11 ms |
312 KB |
Output is correct |
30 |
Correct |
16 ms |
312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
2 ms |
292 KB |
Output is correct |
5 |
Correct |
2 ms |
320 KB |
Output is correct |
6 |
Correct |
2 ms |
200 KB |
Output is correct |
7 |
Correct |
2 ms |
200 KB |
Output is correct |
8 |
Correct |
2 ms |
200 KB |
Output is correct |
9 |
Correct |
2 ms |
292 KB |
Output is correct |
10 |
Correct |
2 ms |
200 KB |
Output is correct |
11 |
Correct |
2 ms |
200 KB |
Output is correct |
12 |
Correct |
2 ms |
200 KB |
Output is correct |
13 |
Correct |
1 ms |
296 KB |
Output is correct |
14 |
Correct |
2 ms |
200 KB |
Output is correct |
15 |
Correct |
2 ms |
200 KB |
Output is correct |
16 |
Correct |
4 ms |
296 KB |
Output is correct |
17 |
Correct |
6 ms |
328 KB |
Output is correct |
18 |
Correct |
17 ms |
300 KB |
Output is correct |
19 |
Correct |
20 ms |
308 KB |
Output is correct |
20 |
Correct |
8 ms |
324 KB |
Output is correct |
21 |
Correct |
19 ms |
312 KB |
Output is correct |
22 |
Correct |
14 ms |
316 KB |
Output is correct |
23 |
Correct |
14 ms |
308 KB |
Output is correct |
24 |
Correct |
15 ms |
324 KB |
Output is correct |
25 |
Correct |
17 ms |
288 KB |
Output is correct |
26 |
Correct |
17 ms |
312 KB |
Output is correct |
27 |
Correct |
17 ms |
328 KB |
Output is correct |
28 |
Correct |
13 ms |
308 KB |
Output is correct |
29 |
Correct |
11 ms |
312 KB |
Output is correct |
30 |
Correct |
16 ms |
312 KB |
Output is correct |
31 |
Correct |
40 ms |
320 KB |
Output is correct |
32 |
Correct |
42 ms |
288 KB |
Output is correct |
33 |
Correct |
82 ms |
424 KB |
Output is correct |
34 |
Correct |
94 ms |
324 KB |
Output is correct |
35 |
Correct |
92 ms |
320 KB |
Output is correct |
36 |
Correct |
72 ms |
300 KB |
Output is correct |
37 |
Correct |
73 ms |
308 KB |
Output is correct |
38 |
Correct |
100 ms |
292 KB |
Output is correct |
39 |
Correct |
77 ms |
320 KB |
Output is correct |
40 |
Correct |
75 ms |
540 KB |
Output is correct |
41 |
Correct |
94 ms |
332 KB |
Output is correct |
42 |
Correct |
77 ms |
312 KB |
Output is correct |
43 |
Correct |
102 ms |
312 KB |
Output is correct |
44 |
Correct |
87 ms |
328 KB |
Output is correct |
45 |
Correct |
63 ms |
320 KB |
Output is correct |
46 |
Correct |
84 ms |
312 KB |
Output is correct |
47 |
Correct |
79 ms |
332 KB |
Output is correct |
48 |
Correct |
90 ms |
316 KB |
Output is correct |
49 |
Correct |
76 ms |
320 KB |
Output is correct |
50 |
Correct |
86 ms |
428 KB |
Output is correct |
51 |
Correct |
79 ms |
320 KB |
Output is correct |
52 |
Correct |
78 ms |
308 KB |
Output is correct |
53 |
Correct |
67 ms |
296 KB |
Output is correct |
54 |
Correct |
78 ms |
436 KB |
Output is correct |
55 |
Correct |
77 ms |
304 KB |
Output is correct |
56 |
Correct |
71 ms |
304 KB |
Output is correct |
57 |
Correct |
71 ms |
308 KB |
Output is correct |
58 |
Correct |
93 ms |
460 KB |
Output is correct |
59 |
Correct |
95 ms |
296 KB |
Output is correct |
60 |
Correct |
95 ms |
308 KB |
Output is correct |