#include<bits/stdc++.h>
#include "xylophone.h"
using namespace std;
const int maxn = 5005;
int a[maxn] , b[maxn];
int val[maxn];
void solve(int n) {
for(int i = 1 ; i < n ; ++i){
a[i] = query(i , i + 1);
}
for(int i = 1 ; i < n - 1 ; ++i){
b[i] = query(i , i + 2);
}
int delta = 1;
val[1] = 0;
val[2] = a[1];
for(int i = 3 ; i <= n ; ++i){
if(a[i - 2] + a[i - 1] != b[i - 2]){
delta = -delta;
}
val[i] = val[i - 1] + delta * a[i - 1];
}
pair<int,int> Min = make_pair(1e9 , 0);
pair<int,int> Max = make_pair(-1e9 , 0);
for(int i = 1 ; i <= n ; ++i){
Min = min(Min , make_pair(val[i] , i));
Max = max(Max , make_pair(val[i] , i));
}
// cout << n << endl;
for(int i = 1 ; i <= n ; ++i){
val[i] = val[i] - Min.first + 1;
if(Min.second > Max.second)val[i] = n - val[i] + 1;
// cout << i << " " << val[i] << endl;
answer(i , val[i]);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
4 ms |
376 KB |
Output is correct |
5 |
Correct |
4 ms |
252 KB |
Output is correct |
6 |
Correct |
4 ms |
248 KB |
Output is correct |
7 |
Correct |
3 ms |
316 KB |
Output is correct |
8 |
Correct |
3 ms |
316 KB |
Output is correct |
9 |
Correct |
3 ms |
312 KB |
Output is correct |
10 |
Correct |
4 ms |
396 KB |
Output is correct |
11 |
Correct |
4 ms |
248 KB |
Output is correct |
12 |
Correct |
4 ms |
248 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
248 KB |
Output is correct |
15 |
Correct |
3 ms |
328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
4 ms |
376 KB |
Output is correct |
5 |
Correct |
4 ms |
252 KB |
Output is correct |
6 |
Correct |
4 ms |
248 KB |
Output is correct |
7 |
Correct |
3 ms |
316 KB |
Output is correct |
8 |
Correct |
3 ms |
316 KB |
Output is correct |
9 |
Correct |
3 ms |
312 KB |
Output is correct |
10 |
Correct |
4 ms |
396 KB |
Output is correct |
11 |
Correct |
4 ms |
248 KB |
Output is correct |
12 |
Correct |
4 ms |
248 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
248 KB |
Output is correct |
15 |
Correct |
3 ms |
328 KB |
Output is correct |
16 |
Correct |
4 ms |
336 KB |
Output is correct |
17 |
Correct |
13 ms |
376 KB |
Output is correct |
18 |
Correct |
19 ms |
320 KB |
Output is correct |
19 |
Correct |
21 ms |
320 KB |
Output is correct |
20 |
Correct |
23 ms |
376 KB |
Output is correct |
21 |
Correct |
23 ms |
376 KB |
Output is correct |
22 |
Correct |
27 ms |
248 KB |
Output is correct |
23 |
Correct |
21 ms |
324 KB |
Output is correct |
24 |
Correct |
25 ms |
328 KB |
Output is correct |
25 |
Correct |
25 ms |
376 KB |
Output is correct |
26 |
Correct |
24 ms |
248 KB |
Output is correct |
27 |
Correct |
25 ms |
568 KB |
Output is correct |
28 |
Correct |
28 ms |
248 KB |
Output is correct |
29 |
Correct |
12 ms |
396 KB |
Output is correct |
30 |
Correct |
24 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
4 ms |
376 KB |
Output is correct |
5 |
Correct |
4 ms |
252 KB |
Output is correct |
6 |
Correct |
4 ms |
248 KB |
Output is correct |
7 |
Correct |
3 ms |
316 KB |
Output is correct |
8 |
Correct |
3 ms |
316 KB |
Output is correct |
9 |
Correct |
3 ms |
312 KB |
Output is correct |
10 |
Correct |
4 ms |
396 KB |
Output is correct |
11 |
Correct |
4 ms |
248 KB |
Output is correct |
12 |
Correct |
4 ms |
248 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
248 KB |
Output is correct |
15 |
Correct |
3 ms |
328 KB |
Output is correct |
16 |
Correct |
4 ms |
336 KB |
Output is correct |
17 |
Correct |
13 ms |
376 KB |
Output is correct |
18 |
Correct |
19 ms |
320 KB |
Output is correct |
19 |
Correct |
21 ms |
320 KB |
Output is correct |
20 |
Correct |
23 ms |
376 KB |
Output is correct |
21 |
Correct |
23 ms |
376 KB |
Output is correct |
22 |
Correct |
27 ms |
248 KB |
Output is correct |
23 |
Correct |
21 ms |
324 KB |
Output is correct |
24 |
Correct |
25 ms |
328 KB |
Output is correct |
25 |
Correct |
25 ms |
376 KB |
Output is correct |
26 |
Correct |
24 ms |
248 KB |
Output is correct |
27 |
Correct |
25 ms |
568 KB |
Output is correct |
28 |
Correct |
28 ms |
248 KB |
Output is correct |
29 |
Correct |
12 ms |
396 KB |
Output is correct |
30 |
Correct |
24 ms |
248 KB |
Output is correct |
31 |
Correct |
43 ms |
424 KB |
Output is correct |
32 |
Correct |
64 ms |
416 KB |
Output is correct |
33 |
Correct |
84 ms |
392 KB |
Output is correct |
34 |
Correct |
104 ms |
376 KB |
Output is correct |
35 |
Correct |
75 ms |
340 KB |
Output is correct |
36 |
Correct |
70 ms |
376 KB |
Output is correct |
37 |
Correct |
79 ms |
452 KB |
Output is correct |
38 |
Correct |
96 ms |
376 KB |
Output is correct |
39 |
Correct |
103 ms |
376 KB |
Output is correct |
40 |
Correct |
109 ms |
356 KB |
Output is correct |
41 |
Correct |
101 ms |
376 KB |
Output is correct |
42 |
Correct |
85 ms |
336 KB |
Output is correct |
43 |
Correct |
130 ms |
380 KB |
Output is correct |
44 |
Correct |
69 ms |
408 KB |
Output is correct |
45 |
Correct |
104 ms |
300 KB |
Output is correct |
46 |
Correct |
106 ms |
424 KB |
Output is correct |
47 |
Correct |
111 ms |
380 KB |
Output is correct |
48 |
Correct |
54 ms |
400 KB |
Output is correct |
49 |
Correct |
112 ms |
376 KB |
Output is correct |
50 |
Correct |
102 ms |
380 KB |
Output is correct |
51 |
Correct |
105 ms |
376 KB |
Output is correct |
52 |
Correct |
101 ms |
460 KB |
Output is correct |
53 |
Correct |
69 ms |
404 KB |
Output is correct |
54 |
Correct |
86 ms |
452 KB |
Output is correct |
55 |
Correct |
99 ms |
464 KB |
Output is correct |
56 |
Correct |
124 ms |
336 KB |
Output is correct |
57 |
Correct |
75 ms |
504 KB |
Output is correct |
58 |
Correct |
99 ms |
376 KB |
Output is correct |
59 |
Correct |
101 ms |
428 KB |
Output is correct |
60 |
Correct |
90 ms |
468 KB |
Output is correct |