#include<bits/stdc++.h>
#include "xylophone.h"
#define ll long long
#define all(v) begin(v), end(v)
#define pi pair<int, int>
#define vi vector<int>
using namespace std;
int a[5005], n;
int p1[5005], p2[5005];
bool thu(int u, int v){
if(v < 1 || v > n) return false;
a[1] = u, a[2] = v;
for(int i = 3; i <= n; i++){
int d1 = p1[i], d2 = p2[i], d3 = abs(a[i-2] - a[i-1]);
if(a[i-2] > a[i-1]){
if(d1 == d2 || d2 == d3){
a[i] = a[i-1] + d1;
}
else{
a[i] = a[i-1] - d1;
}
}
else{
if(d1 == d2 || d2 == d3){
a[i] = a[i-1] - d1;
}
else{
a[i] = a[i-1] + d1;
}
}
}
vector<bool> ch(n, false);
for(int i = 1; i <= n; i++){
if(a[i] < 1 || a[i] > n) return false;
if(ch[a[i]-1]) return false;
if(a[i] == n && !ch[0]) return false;
ch[a[i]-1] = true;
}
return true;
}
void solve(int m){
n = m;
int d = query(1, 2);
for(int i = 3; i <= n; i++){
p1[i] = query(i-1, i), p2[i] = query(i-2, i);
}
for(int v1 = 1; v1 <= n; v1++){
for(int z = -d; z <= d; z+=2*d){
if(thu(v1, v1+z)){
for(int i = 1; i <= n; i++) answer(i, a[i]);
return ;
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
2 ms |
344 KB |
Output is correct |
11 |
Correct |
2 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
2 ms |
344 KB |
Output is correct |
11 |
Correct |
2 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
2 ms |
344 KB |
Output is correct |
17 |
Correct |
5 ms |
344 KB |
Output is correct |
18 |
Correct |
12 ms |
600 KB |
Output is correct |
19 |
Correct |
15 ms |
344 KB |
Output is correct |
20 |
Correct |
11 ms |
436 KB |
Output is correct |
21 |
Correct |
11 ms |
344 KB |
Output is correct |
22 |
Correct |
15 ms |
676 KB |
Output is correct |
23 |
Correct |
9 ms |
344 KB |
Output is correct |
24 |
Correct |
13 ms |
344 KB |
Output is correct |
25 |
Correct |
13 ms |
344 KB |
Output is correct |
26 |
Correct |
12 ms |
452 KB |
Output is correct |
27 |
Correct |
10 ms |
452 KB |
Output is correct |
28 |
Correct |
11 ms |
444 KB |
Output is correct |
29 |
Correct |
12 ms |
344 KB |
Output is correct |
30 |
Correct |
11 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
2 ms |
344 KB |
Output is correct |
11 |
Correct |
2 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
2 ms |
344 KB |
Output is correct |
17 |
Correct |
5 ms |
344 KB |
Output is correct |
18 |
Correct |
12 ms |
600 KB |
Output is correct |
19 |
Correct |
15 ms |
344 KB |
Output is correct |
20 |
Correct |
11 ms |
436 KB |
Output is correct |
21 |
Correct |
11 ms |
344 KB |
Output is correct |
22 |
Correct |
15 ms |
676 KB |
Output is correct |
23 |
Correct |
9 ms |
344 KB |
Output is correct |
24 |
Correct |
13 ms |
344 KB |
Output is correct |
25 |
Correct |
13 ms |
344 KB |
Output is correct |
26 |
Correct |
12 ms |
452 KB |
Output is correct |
27 |
Correct |
10 ms |
452 KB |
Output is correct |
28 |
Correct |
11 ms |
444 KB |
Output is correct |
29 |
Correct |
12 ms |
344 KB |
Output is correct |
30 |
Correct |
11 ms |
344 KB |
Output is correct |
31 |
Correct |
20 ms |
600 KB |
Output is correct |
32 |
Correct |
62 ms |
444 KB |
Output is correct |
33 |
Correct |
58 ms |
464 KB |
Output is correct |
34 |
Correct |
113 ms |
600 KB |
Output is correct |
35 |
Correct |
93 ms |
948 KB |
Output is correct |
36 |
Correct |
50 ms |
708 KB |
Output is correct |
37 |
Correct |
125 ms |
848 KB |
Output is correct |
38 |
Correct |
53 ms |
448 KB |
Output is correct |
39 |
Correct |
77 ms |
848 KB |
Output is correct |
40 |
Correct |
103 ms |
600 KB |
Output is correct |
41 |
Correct |
99 ms |
944 KB |
Output is correct |
42 |
Correct |
51 ms |
708 KB |
Output is correct |
43 |
Correct |
137 ms |
688 KB |
Output is correct |
44 |
Correct |
49 ms |
600 KB |
Output is correct |
45 |
Correct |
62 ms |
452 KB |
Output is correct |
46 |
Correct |
139 ms |
592 KB |
Output is correct |
47 |
Correct |
163 ms |
600 KB |
Output is correct |
48 |
Correct |
62 ms |
948 KB |
Output is correct |
49 |
Correct |
133 ms |
448 KB |
Output is correct |
50 |
Correct |
153 ms |
700 KB |
Output is correct |
51 |
Correct |
73 ms |
960 KB |
Output is correct |
52 |
Correct |
61 ms |
344 KB |
Output is correct |
53 |
Correct |
114 ms |
344 KB |
Output is correct |
54 |
Correct |
105 ms |
592 KB |
Output is correct |
55 |
Correct |
100 ms |
448 KB |
Output is correct |
56 |
Correct |
66 ms |
444 KB |
Output is correct |
57 |
Correct |
104 ms |
444 KB |
Output is correct |
58 |
Correct |
81 ms |
448 KB |
Output is correct |
59 |
Correct |
77 ms |
344 KB |
Output is correct |
60 |
Correct |
80 ms |
692 KB |
Output is correct |