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;
void solve(int N) {
vector<int> A(N+1);
A[1] = 0; A[2] = query(1, 2);
for (int i = 2; i < N; i++)
{
int d13 = query(i-1, i+1), d23 = query(i, i+1);
int d12 = abs(A[i]-A[i-1]); int sign = (A[i]-A[i-1])/d12;
if (d13 == d12 + d23) A[i+1] = A[i] + sign * d23;
else A[i+1] = A[i] - sign * d23;
}
int idMin = min_element(A.begin()+1, A.end()) - A.begin(), idMax = max_element(A.begin()+1, A.end()) - A.begin();
if (idMin > idMax) {swap(idMin, idMax); for (auto &x : A) x = -x;}
int aux = A[idMin];
for (auto &x : A) x += 1-aux;
for (int i = 1; i <= N; 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... |