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;
#define pii pair<int, int>
static int A[5000];
int d[5000];
int V[5000];
void solve(int N) {
for(int i = 0; i<N-1; i++){
d[i] = query(i+1, i+2);
}
int dir =1;
for(int i = 0; i<N-2; i++){
int s = query(i+1, i+3);
if(s<abs(d[i]+d[i+1]*dir)){
dir*=-1;
}
d[i+1] = d[i+1]*dir;
}
V[0] = 0;
pii MIN = pii(0, 0);
pii MAX = pii(0, 0);
for(int i = 1; i<N; i++){
V[i] = V[i-1] + d[i-1];
if(MAX.first<V[i]){
MAX.first = V[i];
MAX.second = i;
}
else if(MIN.first>V[i]){
MIN.first = V[i];
MIN.second = i;
}
}
if(MAX.second<MIN.second){
for(int i = 0; i<N; i++){
V[i] = -V[i];
}
MIN.first = -MAX.first;
}
for(int i = 0; i<N; i++){
V[i]-=MIN.first;
}
for(int i = 0; i<N; i++){
answer(i+1, V[i]+1);
}
}
Compilation message (stderr)
xylophone.cpp:6:12: warning: 'A' defined but not used [-Wunused-variable]
6 | static int A[5000];
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |