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>
using namespace std;
void answer(int a, int b);
int query(int a, int b);
void solve(int n) {
vector<int> ans(n + 1);
vector<int> d1(n + 1);
vector<int> d2(n + 1);
for (int i = 1; i < n; i++) {
d1[i - 1] = query(i, i + 1);
}
for (int i = 2; i < n; i++) {
d2[i - 2] = query(i - 1, i + 1);
}
ans[0] = 0;
ans[1] = d1[0];
int tm = 1;
for (int i = 2; i < n; i++) {
if (d2[i - 2] != d1[i - 1] + d1[i - 2]) {
tm *= -1;
}
ans[i] = ans[i - 1] + d1[i - 1] * tm;
}
int mn = 0, mx = 0;
int mnv = 0, mxv = 0;
for (int i = 1; i < n; i++) {
if (ans[i] < ans[mn]) {
mn = i;
mnv = ans[i];
}
if (ans[i] > ans[mx]) {
mx = i;
mxv = ans[i];
}
}
if (mn < mx) {
for (int i = 0; i < n; i++) {
answer(i + 1, ans[i] - mnv + 1);
}
} else {
for (int i = 0; i < n; i++) {
answer(i + 1, mxv - ans[i] + 1);
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |