# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
577963 | Jomnoi | Xylophone (JOI18_xylophone) | C++17 | 114 ms | 472 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 <bits/stdc++.h>
#include "xylophone.h"
using namespace std;
static int A[5000];
const int MAX_N = 5005;
const int INF = 1e9 + 7;
int arr[MAX_N];
int q1[MAX_N], q2[MAX_N];
void solve(int N) {
for(int i = 1; i <= N; i++) {
if(i - 1 >= 1) {
q1[i] = query(i - 1, i);
}
if(i - 2 >= 1) {
q2[i] = query(i - 2, i);
}
}
arr[1] = 0;
arr[2] = q1[2];
for(int i = 3; i <= N; i++) {
if(q1[i] + q1[i - 1] == q2[i]) {
if(arr[i - 2] < arr[i - 1]) {
arr[i] = arr[i - 1] + q1[i];
}
else {
arr[i] = arr[i - 1] - q1[i];
}
}
else {
if(arr[i - 2] < arr[i - 1]) {
arr[i] = arr[i - 1] - q1[i];
}
else {
arr[i] = arr[i - 1] + q1[i];
}
}
}
int min_value = INF;
for(int i = 1; i <= N; i++) {
min_value = min(min_value, arr[i]);
}
for(int i = 1; i <= N; i++) {
arr[i] -= min_value - 1;
}
int idx_min, idx_max;
for(int i = 1; i <= N; i++) {
if(arr[i] == 1) {
idx_min = i;
}
else if(arr[i] == N) {
idx_max = i;
}
}
if(idx_max < idx_min) {
for(int i = 1; i <= N; i++) {
arr[i] = N - arr[i] + 1;
}
}
for(int i = 1; i <= N; i++) {
answer(i, arr[i]);
}
}
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... |