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 n, mn, i_1, i_n;
vector<int> a(6e3, 0);
vector<int> v1(6e3, 0);
vector<int> v2(6e3, 0);
void solve(int N) {
n = N;
for (int i = 1; i <= n - 1; i++) v1[i] = query(i, i + 1);
for (int i = 1; i <= n - 2; i++) v2[i] = query(i, i + 2);
a[2] = v1[1];
for (int i = 3; i <= n; i++) {
if (a[i - 2] < a[i - 1]) {
a[i] = a[i - 1] + (v2[i - 2] == v1[i - 2] + v1[i - 1] ? v1[i - 1] : -v1[i - 1]);
} else {
a[i] = a[i - 1] + (v2[i - 2] == v1[i - 2] + v1[i - 1] ? -v1[i - 1] : v1[i - 1]);
}
mn = min(mn, a[i]);
}
for (int i = 1; i <= n; i++) {
a[i] += 1 - mn;
if (a[i] == 1) i_1 = i;
if (a[i] == n) i_n = i;
}
for (int i = 1; i <= n; i++) {
if (i_1 > i_n) a[i] = n + 1 - a[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... |