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) {
int res[N+1];
int val = query(1, 2);
res[1] = 0;
res[2] = res[1] + val;
for(int i=3; i<=N; i++) {
int op1 = query(i-1, i);
int op2 = query(i-2, i);
if(op1 + val == op2) {
res[i] = (res[i-2] < res[i-1] ? res[i-1] + op1 : res[i-1] - op1);
}
else {
res[i] = (res[i-2] < res[i-1] ? res[i-1] - op1 : res[i-1] + op1);
}
val = op1;
}
int mx = 0;
for(int i=1; i<=N; i++) mx = max(mx, res[i]);
for(int i=1; i<=N; i++) res[i] += N - mx;
int pos[N+1];
for(int i=1; i<=N; i++) pos[res[i]] = i;
if(pos[1] > pos[N]) {
for(int i=1; i<=N; i++) res[i] = N+1 - res[i];
}
for(int i=1; i<=N; i++) answer(i, res[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... |