#include <bits/stdc++.h>
#include "xylophone.h"
using namespace std;
const int MAX = 5010;
int a[MAX], d[MAX], t[MAX], dir[MAX];
void solve(int n) {
for(int i = 1; i + 1 <= n; ++i) {
d[i] = query(i, i + 1);
}
for(int i = 1; i + 2 <= n; ++i) {
t[i] = query(i, i + 2);
}
d[0] = 1;
for(int i = 1; i <= n; ++i) {
if(d[i] + d[i + 1] == t[i]) {
dir[i + 1] = dir[i];
} else {
dir[i + 1] = dir[i] ^ 1;
}
a[i] = a[i - 1] + (dir[i] ? d[i - 1] : -d[i - 1]);
}
int mn = 1, mx = 1;
for(int i = 1; i <= n; ++i) {
if(a[i] < a[mn]) mn = i;
if(a[i] > a[mx]) mx = i;
}
int x = a[mn];
for(int i = 1; i <= n; ++i) {
a[i] = a[i] - x + 1;
}
if(mn > mx) {
for(int i = 1; i <= n; ++i) {
a[i] = n - a[i] + 1;
}
}
for(int i = 1; i <= n; ++i) {
answer(i, a[i]);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Incorrect |
3 ms |
248 KB |
Wrong Answer [4] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Incorrect |
3 ms |
248 KB |
Wrong Answer [4] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Incorrect |
3 ms |
248 KB |
Wrong Answer [4] |
4 |
Halted |
0 ms |
0 KB |
- |