# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
333475 | benson1029 | Xylophone (JOI18_xylophone) | C++14 | 107 ms | 640 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>
using namespace std;
int rv1[5005],rv2[5005];
int sign[5005];
int a[5005];
void solve(int N) {
for(int i=1; i<=N-1; i++) {
rv1[i] = query(i, i+1);
}
for(int i=1; i<=N-2; i++) {
rv2[i] = query(i, i+2);
}
for(sign[1] = 0; sign[1] <= 1; sign[1]++) {
for(int i=1; i<=N-2; i++) {
if(rv2[i] == rv1[i+1] + rv1[i]) {
sign[i+1] = sign[i];
} else {
sign[i+1] = 1 - sign[i];
}
}
a[1] = 0;
int mn = 0;
for(int i=2; i<=N; i++) {
if(sign[i-1] == 0) a[i] = a[i-1] + rv1[i-1];
else a[i] = a[i-1] - rv1[i-1];
mn = min(mn, a[i]);
}
int pos1, posN;
for(int i=1; i<=N; i++) {
a[i] += (1-mn);
if(a[i] == 1) pos1 = i;
else if(a[i] == N) posN = i;
}
if(pos1 < posN) {
for(int i=1; i<=N; i++) {
answer(i, a[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... |