# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
642484 | Edbert2397 | Xylophone (JOI18_xylophone) | C++14 | 119 ms | 468 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;
// static int A[5000];
int a[5005],b[5005],c[5005],arr[5005];
void solve(int n) {
for(int i = 1;i<n;i++){
a[i] = query(i,i + 1);
}
for(int i = 3;i<=n;i++){
b[i] = query(i-2,i);
}
c[1] = a[1];
for(int i = 2;i<n;i++){
c[i] = a[i];
if(c[i-1] < 0){
c[i] = -c[i];
}
if(a[i-1] + a[i] != b[i + 1]){
c[i] = -c[i];
}
}
arr[1] = 0;
int mini = 0;
for(int i = 2;i<=n;i++){
arr[i] = arr[i-1] + c[i-1];
mini = min(mini,arr[i]);
}
int l,r;
for(int i = 1;i<=n;i++){
arr[i] += (-mini) + 1;
if(arr[i] == 1) l = i;
if(arr[i] == n) r = i;
}
if(l > r){
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... |