#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
void solve(int N) {
vector<int> d(N - 1);
for (int i = 0; i < N - 1; i++) {
d[i] = query(i + 1, i + 2);
}
for (int i = 1; i < N - 1; i++) {
if (query(i, i + 2) != abs(d[i - 1]) + d[i]) {
d[i] *= d[i - 1] < 0 ? 1 : -1;
}
}
for (int r = 0; r < 2; r++) {
vector<int> p = d;
p.insert(p.begin(), 0);
partial_sum(p.begin(), p.end(), p.begin());
int Min = *min_element(p.begin(), p.end());
int good = 0;
for (int &v : p) {
v -= Min - 1;
if (v == 1 && good == 0) {
good++;
}
if (v == N && good == 1) {
good++;
}
}
if (good == 2) {
for (int i = 0; i < N; i++) {
answer(1 + i, p[i]);
}
}
for (int i = 0; i < N - 1; i++) {
d[i] *= -1;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Incorrect |
1 ms |
208 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Incorrect |
1 ms |
208 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Incorrect |
1 ms |
208 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |