#include "xylophone.h"
static int A[5000];
void solve(int N){
int n = N;
int dizi[n];
for(int i = 0; i < n - 1; i++){
dizi[i] = query(i, i + 1);
}
int R[n];
R[0] = 0;
R[1] = dizi[0];
for(int i = 1; i < n - 1; i++){
int d_total = query(i - 1, i + 1);
int d_prev = dizi[i - 1];
int d_curr = dizi[i];
int direction = R[i] - R[i - 1];
if(d_total == d_prev + d_curr){
if(direction > 0){
R[i + 1] = R[i] + d_curr;
}
else{
R[i + 1] = R[i] - d_curr;
}
}
else{
if(direction > 0){
R[i + 1] = R[i] - d_curr;
}
else{
R[i + 1] = R[i] + d_curr;
}
}
}
int min_R = R[0];
int max_R = R[0];
int idx_min = 0;
int idx_max = 0;
for(int i = 1; i < n; i++){
if(R[i] < min_R){
min_R = R[i];
idx_min = i;
}
if(R[i] > max_R){
max_R = R[i];
idx_max = i;
}
}
if(idx_min < idx_max){
int C = 1 - min_R;
for(int i = 0; i < n; i++){
answer(i, R[i] + C);
}
}
else{
for(int i = 0; i < n; i++){
answer(i, max_R - R[i] + 1);
}
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |