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;
#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
using ll = long long;
typedef pair<int, int> pii;
namespace {
const int MXN = 5005;
int a[MXN];
}
void solve(int n) {
a[1] = 0;
a[2] = query(1, 2);
int pre = a[2];
FOR(i, 3, n + 1) {
int x = query(i - 2, i), y = query(i - 1, i);
if (pre + y == x) {
if (a[i - 2] < a[i - 1]) a[i] = a[i - 1] + y;
else a[i] = a[i - 1] - y;
} else {
if (a[i - 2] < a[i - 1]) a[i] = a[i - 1] - y;
else a[i] = a[i - 1] + y;
}
pre = y;
}
int smlid = min_element(a + 1, a + n + 1) - a;
int bigid = max_element(a + 1, a + n + 1) - a;
if (smlid > bigid) {
FOR(i, 1, n + 1) a[i] = -a[i];
}
int sml = *min_element(a + 1, a + n + 1);
FOR(i, 1, n + 1) a[i] += -sml + 1;
FOR(i, 1, n + 1) 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... |