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"
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MN = 1e5 + 5;
void solve(int n) {
vector<int> d(n + 1), up(n + 1), a(n + 1);
for (int i = 1; i <= n - 1; i++) {
d[i] = query(i, i + 1);
}
a[1] = 0, a[2] = d[1];
up[1] = 1;
for (int i = 1; i <= n - 2; i++) {
int j = i + 1;
int q = query(i, i + 2);
if (d[i] + d[i + 1] == q) up[j] = up[i];
else up[j] = !up[i];
}
for (int i = 2; i <= n - 1; i++) {
if (up[i]) a[i + 1] = a[i] + d[i];
else a[i + 1] = a[i] - d[i];
}
int mn = min_element(a.begin() + 1, a.end()) - a.begin();
int mx = max_element(a.begin() + 1, a.end()) - a.begin();
if (mn > mx) for (int i = 1; i <= n; i++) a[i] = -a[i];
int m = *min_element(a.begin() + 1, a.end());
for (int i = 1; i <= n; i++) {
a[i] = a[i] - m + 1;
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... |