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>
#define Loop(x, l, r) for (ll x = (l); x < (r); ++x)
typedef long long ll;
typedef std::pair<int,int> pii;
using namespace std;
static int A[5000];
void solve(int N)
{
A[1] = query(1, 2);
Loop (i,2,N) {
int x = query(i, i+1);
int y = query(i-1, i+1);
if (max(A[i-2], A[i-1]+x) - min(A[i-2], A[i-1]) == y)
A[i] = A[i-1]+x;
else
A[i] = A[i-1]-x;
}
pii mn = {1,1};
pii mx = {-1,-1};
Loop (i,0,N) {
mn = min(mn, {A[i], i});
mx = max(mx, {A[i], i});
}
Loop (i,0,N)
A[i] -= mn.first;
if (mn.second > mx.second) {
Loop (i,0,N)
A[i] = N-1-A[i];
}
//Loop (i,0,N)
// cerr << A[i]+1 << ' ';
//cerr << '\n';
Loop (i,0,N)
answer(i+1, A[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... |