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 <bits/stdc++.h>
#include "xylophone.h"
//~ #include "grader.cpp"
using namespace std;
static int A[5000];
int ask(int s, int t){
return query(s + 1, t + 1);
}
void solve(int n){
vector <int> a(n);
a[0] = 0;
a[1] = a[0] + ask(0, 1);
for(int i = 0 ; i + 2 < n ; i++){
int cur = abs(a[i] - a[i + 1]);
int c = ask(i, i + 2);
if(c == cur){
int d = ask(i + 1, i + 2);
if(a[i + 1] > a[i]){
a[i + 2] = a[i + 1] - d;
}
else{
a[i + 2] = a[i + 1] + d;
}
}
else{
int d = ask(i + 1, i + 2);
if(c == d){
if(a[i + 1] > a[i]){
a[i + 2] = a[i + 1] - d;
}
else{
a[i + 2] = a[i + 1] + d;
}
}
else{
if(a[i] > a[i + 1]){
a[i + 2] = a[i] - d;
}
else{
a[i + 2] = a[i] + d;
}
}
}
}
int mn = 0, mx = 0;
for(int i = 0 ; i < n ; i++){
if(a[i] < a[mn]) mn = i;
if(a[i] > a[mx]) mx = i;
}
if(mx < mn){
for(auto &i : a){
i *= -1;
}
}
mn = 1e9;
for(auto &i : a) mn = min(mn, i);
for(auto &i : a) i = i - mn + 1;
for(int i = 0 ; i < n ; i++){
answer(i + 1, a[i]);
}
}
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... |