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 <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int arr[5005];
void solve(int n) {
arr[1]=0;
arr[2]=query(1,2);
int temp1,temp2;
for (int x=3;x<=n;x++){
temp1=query(x-2,x);
temp2=query(x-1,x);
arr[x]=arr[x-1]+temp2;
if (max(arr[x],max(arr[x-1],arr[x-2]))-min(arr[x],min(arr[x-1],arr[x-2]))!=temp1){
arr[x]=arr[x-1]-temp2;
}
}
int __min=1000000;
for (int x=1;x<=n;x++) __min=min(__min,arr[x]);
for (int x=1;x<=n;x++) arr[x]-=__min-1;
int lo,hi;
for (int x=1;x<=n;x++){
if (arr[x]==1) lo=x;
if (arr[x]==n) hi=x;
}
if (lo>hi)
for (int x=1;x<=n;x++) arr[x]=n-arr[x]+1;
for (int x=1;x<=n;x++) answer(x,arr[x]);
}
Compilation message (stderr)
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:33:2: warning: 'hi' may be used uninitialized in this function [-Wmaybe-uninitialized]
33 | if (lo>hi)
| ^~
xylophone.cpp:33:2: warning: 'lo' may be used uninitialized in this function [-Wmaybe-uninitialized]
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |