# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
155136 | karma | Xylophone (JOI18_xylophone) | C++14 | 3 ms | 376 KiB |
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 ll long long
using namespace std;
const int N = 6006;
int a[N], d[2][N], mx, mn, up;
void solve(int n) {
for(int i = 1; i < n; ++i) {
d[1][i - 1] = query(i, i + 1);
if(i > 1) d[2][i - 2] = query(i - 1, i + 1);
}
a[0] = mn = mx = 0, a[1] = d[1][0]; up = 1;
if(n > 1) {
if(a[mx] < a[1]) mx = 1;
if(a[mn] > a[1]) mn = 1;
}
for(int i = 2; i < n; ++i) {
if(d[1][i - 1] + d[1][i - 2] != d[2][i - 2]) up *= (-1);
a[i] = a[i - 1] + up * d[1][i - 1];
if(a[mx] < a[i]) mx = i;
if(a[mn] > a[i]) mn = i;
}
if(mn < mx) {
mn = a[mn];
for(int i = 0; i < n; ++i) answer(i + 1, a[i] - mn + 1);
} else {
mx = a[mx];
for(int i = 0; i < n; ++i) answer(i + 1, mx - a[i] + 1);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |