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>
void solve(int n) {
std::ios::sync_with_stdio(0); std::cin.tie(0);
std::vector <int> d1, d2, ans(n);
for (int i = 0; i < n - 1; i++) {
d1.push_back(query(i + 1, i + 2));
d2.push_back(query(i + 1, i + 3));
}
ans[0] = 0;
ans[1] = d1[0];
for (int i = 2; i < n; i++) {
ans[i] = ans[i - 1];
if (d1[i - 2] + d1[i - 1] == d2[i - 2]) {
if(ans[i - 2] < ans[i - 1]) ans[i] += d1[i - 1];
else ans[i] -= d1[i - 1];
} else {
if (ans[i - 2] < ans[i - 1]) ans[i] -= d1[i - 1];
else ans[i] += d1[i - 1];
}
}
int l = 1 << 30;
for (int x : ans) l = std::min(l, x);
for (int& x : ans) x -= l - 1;
if (min_element(ans.begin(), ans.end()) > max_element(ans.begin(), ans.end())) {
for (int& x : ans) x = n - x + 1;
}
for (int i = 0; i < n; i++) answer(i + 1, ans[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... |