#include "xylophone.h"
const int MAX_N = 5000;
int v[1+MAX_N];
int win2[1+MAX_N], win3[1+MAX_N];
void solve(int N) {
int semn = 1;
int vmin, pmin, vmax, pmax;
for(int i = 1; i < N; ++i)
win2[i] = query(i, i + 1);
for(int i = 2; i < N; ++i)
win3[i] = query(i - 1, i + 1);
v[1] = 0;
v[2] = win2[1];
for(int i = 3; i <= N; ++i) {
if(win2[i - 2] + win2[i - 1] != win3[i - 1])
semn = semn * (-1);
v[i] = v[i - 1] + semn * win2[i - 1];
}
vmin = 1000000000;
vmax =-1000000000;
pmin = pmax = 0;
for(int i = 1; i <= N; ++i) {
if(v[i] > vmax) {
vmax = v[i];
pmax = i;
}
if(v[i] < vmin) {
vmin = v[i];
pmin = i;
}
}
for(int i = 1; i <= N; ++i) {
v[i] = v[i] - vmin + 1;
if(pmin > pmax)
v[i] = N - v[i] + 1;
answer(i, v[i]);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
276 KB |
Output is correct |
2 |
Correct |
2 ms |
452 KB |
Output is correct |
3 |
Correct |
2 ms |
456 KB |
Output is correct |
4 |
Correct |
3 ms |
456 KB |
Output is correct |
5 |
Correct |
3 ms |
508 KB |
Output is correct |
6 |
Correct |
4 ms |
520 KB |
Output is correct |
7 |
Correct |
2 ms |
532 KB |
Output is correct |
8 |
Correct |
3 ms |
540 KB |
Output is correct |
9 |
Correct |
4 ms |
540 KB |
Output is correct |
10 |
Correct |
2 ms |
540 KB |
Output is correct |
11 |
Correct |
3 ms |
540 KB |
Output is correct |
12 |
Correct |
4 ms |
540 KB |
Output is correct |
13 |
Correct |
4 ms |
540 KB |
Output is correct |
14 |
Correct |
4 ms |
540 KB |
Output is correct |
15 |
Correct |
3 ms |
540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
276 KB |
Output is correct |
2 |
Correct |
2 ms |
452 KB |
Output is correct |
3 |
Correct |
2 ms |
456 KB |
Output is correct |
4 |
Correct |
3 ms |
456 KB |
Output is correct |
5 |
Correct |
3 ms |
508 KB |
Output is correct |
6 |
Correct |
4 ms |
520 KB |
Output is correct |
7 |
Correct |
2 ms |
532 KB |
Output is correct |
8 |
Correct |
3 ms |
540 KB |
Output is correct |
9 |
Correct |
4 ms |
540 KB |
Output is correct |
10 |
Correct |
2 ms |
540 KB |
Output is correct |
11 |
Correct |
3 ms |
540 KB |
Output is correct |
12 |
Correct |
4 ms |
540 KB |
Output is correct |
13 |
Correct |
4 ms |
540 KB |
Output is correct |
14 |
Correct |
4 ms |
540 KB |
Output is correct |
15 |
Correct |
3 ms |
540 KB |
Output is correct |
16 |
Correct |
6 ms |
540 KB |
Output is correct |
17 |
Correct |
9 ms |
540 KB |
Output is correct |
18 |
Correct |
14 ms |
540 KB |
Output is correct |
19 |
Correct |
21 ms |
540 KB |
Output is correct |
20 |
Correct |
8 ms |
548 KB |
Output is correct |
21 |
Correct |
29 ms |
556 KB |
Output is correct |
22 |
Correct |
24 ms |
564 KB |
Output is correct |
23 |
Correct |
7 ms |
564 KB |
Output is correct |
24 |
Correct |
22 ms |
564 KB |
Output is correct |
25 |
Correct |
17 ms |
580 KB |
Output is correct |
26 |
Correct |
23 ms |
580 KB |
Output is correct |
27 |
Correct |
8 ms |
580 KB |
Output is correct |
28 |
Correct |
17 ms |
580 KB |
Output is correct |
29 |
Correct |
8 ms |
580 KB |
Output is correct |
30 |
Correct |
8 ms |
580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
276 KB |
Output is correct |
2 |
Correct |
2 ms |
452 KB |
Output is correct |
3 |
Correct |
2 ms |
456 KB |
Output is correct |
4 |
Correct |
3 ms |
456 KB |
Output is correct |
5 |
Correct |
3 ms |
508 KB |
Output is correct |
6 |
Correct |
4 ms |
520 KB |
Output is correct |
7 |
Correct |
2 ms |
532 KB |
Output is correct |
8 |
Correct |
3 ms |
540 KB |
Output is correct |
9 |
Correct |
4 ms |
540 KB |
Output is correct |
10 |
Correct |
2 ms |
540 KB |
Output is correct |
11 |
Correct |
3 ms |
540 KB |
Output is correct |
12 |
Correct |
4 ms |
540 KB |
Output is correct |
13 |
Correct |
4 ms |
540 KB |
Output is correct |
14 |
Correct |
4 ms |
540 KB |
Output is correct |
15 |
Correct |
3 ms |
540 KB |
Output is correct |
16 |
Correct |
6 ms |
540 KB |
Output is correct |
17 |
Correct |
9 ms |
540 KB |
Output is correct |
18 |
Correct |
14 ms |
540 KB |
Output is correct |
19 |
Correct |
21 ms |
540 KB |
Output is correct |
20 |
Correct |
8 ms |
548 KB |
Output is correct |
21 |
Correct |
29 ms |
556 KB |
Output is correct |
22 |
Correct |
24 ms |
564 KB |
Output is correct |
23 |
Correct |
7 ms |
564 KB |
Output is correct |
24 |
Correct |
22 ms |
564 KB |
Output is correct |
25 |
Correct |
17 ms |
580 KB |
Output is correct |
26 |
Correct |
23 ms |
580 KB |
Output is correct |
27 |
Correct |
8 ms |
580 KB |
Output is correct |
28 |
Correct |
17 ms |
580 KB |
Output is correct |
29 |
Correct |
8 ms |
580 KB |
Output is correct |
30 |
Correct |
8 ms |
580 KB |
Output is correct |
31 |
Correct |
40 ms |
584 KB |
Output is correct |
32 |
Correct |
57 ms |
588 KB |
Output is correct |
33 |
Correct |
83 ms |
588 KB |
Output is correct |
34 |
Correct |
90 ms |
716 KB |
Output is correct |
35 |
Correct |
68 ms |
716 KB |
Output is correct |
36 |
Correct |
82 ms |
716 KB |
Output is correct |
37 |
Correct |
95 ms |
716 KB |
Output is correct |
38 |
Correct |
107 ms |
716 KB |
Output is correct |
39 |
Correct |
87 ms |
724 KB |
Output is correct |
40 |
Correct |
102 ms |
724 KB |
Output is correct |
41 |
Correct |
94 ms |
724 KB |
Output is correct |
42 |
Correct |
86 ms |
724 KB |
Output is correct |
43 |
Correct |
33 ms |
724 KB |
Output is correct |
44 |
Correct |
81 ms |
724 KB |
Output is correct |
45 |
Correct |
91 ms |
724 KB |
Output is correct |
46 |
Correct |
78 ms |
724 KB |
Output is correct |
47 |
Correct |
75 ms |
724 KB |
Output is correct |
48 |
Correct |
77 ms |
724 KB |
Output is correct |
49 |
Correct |
87 ms |
724 KB |
Output is correct |
50 |
Correct |
91 ms |
724 KB |
Output is correct |
51 |
Correct |
79 ms |
724 KB |
Output is correct |
52 |
Correct |
85 ms |
724 KB |
Output is correct |
53 |
Correct |
63 ms |
724 KB |
Output is correct |
54 |
Correct |
49 ms |
724 KB |
Output is correct |
55 |
Correct |
36 ms |
724 KB |
Output is correct |
56 |
Correct |
57 ms |
724 KB |
Output is correct |
57 |
Correct |
88 ms |
724 KB |
Output is correct |
58 |
Correct |
84 ms |
724 KB |
Output is correct |
59 |
Correct |
45 ms |
724 KB |
Output is correct |
60 |
Correct |
73 ms |
724 KB |
Output is correct |