#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
#define MAXN 5010
int diff[MAXN], diffsign[MAXN];
void solve(int n) {
for (int i = 1; i < n; i++) {
diff[i] = query(i, i+1);
}
for (int i = 1; i < n-1; i++) {
int am = query(i, i+2);
if (am != diff[i]+diff[i+1]) diffsign[i+1] = 1;
}
for (int i = 2; i < n; i++) {
if (diffsign[i] && diff[i-1] > 0) diff[i]*=-1;
if (!diffsign[i] && diff[i-1] < 0) diff[i]*=-1;
}
int sum = accumulate(diff+1, diff+n, 0);
if (sum < 0) {
for (int i = 1; i < n; i++) diff[i]*=-1;
}
int val = 0, mn = 0;
for (int i = 1; i < n; i++) {
val += diff[i];
printf("%d %d\n", diff[i], val);
mn = min(mn, val);
}
val = -mn;
val++;
for (int i = 1; i <= n; i++) {
answer(i, val);
val += diff[i];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |