#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
int ans[5005];
int diff[5005];
void solve(int N) {
diff[1] = query(1, 2);
int cur = diff[1];
int mini = 0, maxi = cur;
bool check = true;
for (int i = 2; i < N; ++i) {
int res = query(i, i + 1);
if (res + abs(diff[i - 1]) == query(i - 1, i + 1)) {
if (diff[i - 1] < 0) diff[i] = -res;
else diff[i] = res;
}
else {
if (diff[i - 1] > 0) diff[i] = -res;
else diff[i] = res;
}
cur += diff[i];
if (mini > cur) check = false, mini = cur;
else if (maxi < cur) check = true, maxi = cur;
}
int offset = 1 - mini;
if (!check) offset = 1 - maxi;
cur = offset;
for (int i = 1; i <= N; i++) {
answer(i, cur);
if (!check) cur -= diff[i];
else cur += diff[i];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
4 ms |
208 KB |
Output is correct |
5 |
Incorrect |
3 ms |
208 KB |
Wrong Answer [4] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
4 ms |
208 KB |
Output is correct |
5 |
Incorrect |
3 ms |
208 KB |
Wrong Answer [4] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
4 ms |
208 KB |
Output is correct |
5 |
Incorrect |
3 ms |
208 KB |
Wrong Answer [4] |
6 |
Halted |
0 ms |
0 KB |
- |