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 <bits/stdc++.h>
#include "xylophone.h"
using namespace std;
int const N = 5005;
int a[N];
void solve(int n) {
for (int i = 0; i + 1 < n; ++i) {
a[i+1] = query(i + 1, i + 2);
}
for (int i = 0; i + 2 < n; ++i) {
int t = query(i + 1, i + 3);
if (t == abs(a[i+1]) + abs(a[i+2])) {
if (a[i+1] < 0) a[i+2] *= -1;
} else {
if (a[i+1] > 0) a[i+2] *= -1;
}
}
partial_sum(a, a + n, a);
int mn = *min_element(a, a + n);
int sw = 0;
for (int i = 0; i < n; ++i) {
a[i] -= mn - 1;
if (sw == 0) {
if (a[i] == 1) sw = -1;
else if (a[i] == n) sw = 1;
}
}
if (sw) {
for (int i = 0; i < n; ++i) {
a[i] = n - a[i] + 1;
}
}
for (int i = 0; i < n; ++i) {
answer(i + 1, 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... |