This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "xylophone.h"
static int A[5000];
void solve(int N) {
int ni = 1, fi = 2, lv = -1;
while (query(1, ni) != N - 1)ni++;
answer(ni, N);
for (int i = ni + 1; i <= N; i++) {
int qv = query(ni, i);
int v1 = N - qv;
if (qv == lv) {
int qv2 = query(i - 1, i);
v1 += qv2;
}
answer(i, v1);
lv = qv;
}
lv = -1;
for (int i = ni - 1; i >= 1; i--) {
int qv = query(i, ni);
if (qv == N - 1) {
fi = i;
answer(fi, 1);
break;
}
int v1 = N - qv;
if (qv == lv) {
int qv2 = query(i, i + 1);
v1 += qv2;
}
answer(i, v1);
lv = qv;
}
lv = -1;
for (int i = fi - 1; i >= 1; i--) {
int qv1 = query(i, fi), qv2 = query(i, i + 1);
int v1 = 1 + qv1;
if (qv1 == lv) {
v1 -= qv2;
}
answer(i, v1);
lv = qv1;
}
}
Compilation message (stderr)
xylophone.cpp:3:12: warning: 'A' defined but not used [-Wunused-variable]
static int A[5000];
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |