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"
#include <bits/stdc++.h>
using namespace std;
int re[300005];
int a[300005];
int b[300005];
void solve(int N) {
for (int i = 1; i <= N - 1; i++) {
a[i] = query(i, i + 1);
}
for (int i = 1; i <= N - 2; i++) {
b[i] = query(i, i + 2);
}
re[1] = 1;
for (int i = 1; i <= N - 2; i++) {
if (a[i] + a[i + 1] == b[i]) {
re[i + 1] = re[i];
} else {
re[i + 1] = -re[i];
}
}
a[N] = 0;
int Min = 0;
for (int i = N - 1; i >= 1; i--) {
a[i] = a[i + 1] - re[i] * a[i];
Min = min(Min, a[i]);
}
for (int i = 1; i <= N; i++) {
a[i] = a[i] - Min + 1;
}
for (int i = 1; i <= N; i++) {
if (a[i] == 1) {
break;
}
if (a[i] == N) {
for (int j = 1; j <= N; j++) {
a[j] = N + 1 - a[j];
}
break;
}
}
for (int i = 1; i <= N; i++) {
answer(i, a[i]);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |