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>
using namespace std;
#define REP(i, j, k) for (int i = j; i < k; i++)
void solve(int n) {
vector<int> a(n + 5, 0);
if (n == 1) {
answer(1, 1);
return;
}
a[2] = a[1] + query(1, 2);
int sign = a[2] > a[1] ? 1 : -1;
REP (i, 3, n + 1) {
int fi = query(i - 1, i), se = query(i - 2, i);
if (abs(a[i - 1] - a[i - 2]) + fi != se) {
sign = -sign;
}
a[i] = a[i - 1] + fi * sign;
}
int mn = 0;
REP (i, 1, n + 1) mn = min(mn, a[i]);
REP (i, 1, n + 1) a[i] -= mn;
REP (i, 1, n + 1) {
if (a[i] == 0) break;
if (a[i] == n - 1) {
REP (j, 1, n + 1) a[j] = n - a[j] - 1;
break;
}
}
REP (i, 1, n + 1) answer(i, 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... |