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"
using namespace std;
void solve(int N){
int lst[5100];
int q[5100];
lst[1] = 0;
lst[2] = 0 + query(1, 2);
int big = -1100100;
int ind = 0;
int small = 1100100;
int ind1 = 0;
if(lst[1] > big){
big = lst[1];
ind = 1;
}
if(lst[1] < small){
small = lst[1];
ind1 = 1;
}
if(lst[2] > big){
big = lst[2];
ind = 2;
}
if(lst[2] < small){
small = lst[2];
ind1 = 2;
}
for(int i = 3; i <= N; i++){
int v = query(i - 1,i);
q[i] = query(i - 2,i);
if(lst[i - 1] < lst[i - 2]){
if(q[i] == lst[i - 2] - lst[i - 1] + v){
lst[i] = lst[i - 1] - v;
}
else{
lst[i] = lst[i - 1] + v;
}
}
else{
if(q[i] == lst[i - 1] - lst[i - 2] + v){
lst[i] = lst[i - 1] + v;
}
else{
lst[i] = lst[i - 1] - v;
}
}
if(lst[i] > big){
big = lst[i];
ind = i;
}
if(lst[i] < small){
small = lst[i];
ind1 = i;
}
}
if(ind1 > ind){
int temp = small;
small = big * (-1);
big = temp * (-1);
}
for(int i = 1; i <= N; i++){
if(ind1 > ind){
lst[i] = lst[i] * (-1) - small + 1;
}
else{
lst[i] = lst[i] - small + 1;
}
}
//printf("%d\n",lst[1]);
//printf("%d %d\n",small,big);
for(int i = 1; i <= N; i++){
answer(i,lst[i]);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |