# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
502279 | vrohak | Xylophone (JOI18_xylophone) | C++14 | 111 ms | 368 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;
void solve(int n) {
int A[n];
A[0] = 0;
int D[n - 1];
int T[n - 2];
for(int i = 1; i < n; i++) {
D[i - 1] = query(i, i + 1);
}
for(int i = 2; i < n; i++) {
T[i - 2] = query(i - 1, i + 1);
}
A[1] = D[0];
bool up = true;
for(int i = 2; i < n; i++) {
if(D[i - 2] + D[i - 1] != T[i - 2]) {
up = !up;
}
A[i] = A[i - 1] + D[i - 1] * ((int)up * 2 - 1);
}
int rj1[n+1], rj2[n+1];
int mx = 0, mn = 0x3f3f3f3f;
int idx1 = 0, idx2 = 0, pt1=query(1, n);
for(int i = 0; i < n; i++) {
mn = min(mn, A[i]);
}
mn = (-1)*mn+1;
for(int i=0;i<n;i++){
rj1[i] = A[i]+mn;
rj2[i] = -A[i];
}
mn=0x3f3f3f3f;
for(int i = 0; i < n; i++) {
mn = min(mn, rj2[i]);
}
mn = (-1)*mn+1;
for(int i=0;i<n;i++) rj2[i]+=mn;
for(int i=0;i<n;i++){
if(rj1[i] == 1) idx1 = i;
if(rj1[i] == n) idx2 = i;
}
if(idx1 < idx2) {
for(int i = 0; i < n; i++) {
answer(i + 1, rj1[i]);
}
} else {
for(int i = 0; i < n; i++) {
answer(i + 1, rj2[i]);
}
}
return;
}
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... |