#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
void solve(int N) {
int A[N+1], B[N+1];
A[1] = B[1] = 500069;
int ma = 1, mb = 1;
for (int i = 2; i <= N; i++) {
int q1 = query(i-1, i);
if (i == 2) {
A[2] = A[1] + q1;
B[2] = B[1] - q1;
} else {
int q2 = query(i-2, i);
if (A[i-2] < A[i-1]) {
if (q2 == q1 + A[i-1] - A[i-2]) {
A[i] = A[i-1] + q1;
B[i] = B[i-1] - q1;
} else {
A[i] = A[i-1] - q1;
B[i] = B[i-1] + q1;
}
} else {
if (q2 == q1 + A[i-2] - A[i-1]) {
A[i] = A[i-1] - q1;
B[i] = B[i-1] + q1;
} else {
A[i] = A[i-1] + q1;
B[i] = B[i-1] - q1;
}
}
}
ma = A[ma] > A[i] ? i : ma;
mb = B[mb] > B[i] ? i : mb;
}
if (ma < mb) {
int sub = A[ma] - 1;
for (int i = 1; i <= N; i++) {
answer(i, A[i] - sub);
}
} else {
int sub = B[ma] - 1;
for (int i = 1; i <= N; i++) {
answer(i, B[i] - sub);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
296 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
2 ms |
208 KB |
Output is correct |
5 |
Incorrect |
2 ms |
208 KB |
Wrong Answer [4] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
296 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
2 ms |
208 KB |
Output is correct |
5 |
Incorrect |
2 ms |
208 KB |
Wrong Answer [4] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
296 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
2 ms |
208 KB |
Output is correct |
5 |
Incorrect |
2 ms |
208 KB |
Wrong Answer [4] |
6 |
Halted |
0 ms |
0 KB |
- |