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;
const int MAX = 5010;
int a[MAX], d[MAX], t[MAX], dir[MAX];
void solve(int n) {
for(int i = 1; i + 1 <= n; ++i) {
d[i] = query(i, i + 1);
}
for(int i = 1; i + 2 <= n; ++i) {
t[i] = query(i, i + 2);
}
a[1] = 1;
dir[1] = 1;
for(int i = 1; i < n; ++i) {
if(d[i] + d[i + 1] == t[i]) {
dir[i + 1] = dir[i];
} else {
dir[i + 1] = -dir[i];
}
a[i + 1] = a[i] + dir[i] * d[i];
}
int mn = 1, mx = 1;
for(int i = 1; i <= n; ++i) {
if(a[i] < a[mn]) mn = i;
if(a[i] > a[mx]) mx = i;
}
int x = a[mn];
for(int i = 1; i <= n; ++i) {
a[i] = a[i] - x + 1;
}
if(mn > mx) {
for(int i = 1; i <= n; ++i) {
a[i] = n - a[i] + 1;
}
}
for(int i = 1; i <= n; ++i) {
answer(i, a[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... |