# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
312947 | sofapuden | Xylophone (JOI18_xylophone) | C++14 | 129 ms | 512 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 A[5005];
void solve(int n) {
A[1] = 0;
A[2] = query(1,2);
for(int i = 2; i < n; ++i){
int a = query(i,i+1);
int b = query(i-1,i+1);
A[i+1] = A[i] + a*(A[i]-A[i-1] < 0 ? 1 : -1)*(b == a + abs(A[i]-A[i-1]) ? -1 : 1);
}
int mi = *min_element(A+1, A+1+n);
int l, r;
for(int i = 1; i <= n; ++i){
A[i]-=mi;
if(A[i] == 0)l = i;
if(A[i] == n-1)r = i;
}
bool ok = l < r;
for(int i = 1; i <= n; ++i)answer(i,ok ? A[i]+1 : n-A[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... |