# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1008882 | vjudge1 | Xylophone (JOI18_xylophone) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
const int MAX = 5002;
int a[MAX];
void solve(int n) {
for (int i = 2; i <= n; i++) {
int x = query(1, i);
int y = query(i - 1, i);
if (abs(a[i - 1] + y) == x) a[i] = a[i - 1] + y;
else a[i] = a[i - 1] - y;
}
int u = 0;
a[0] = INT_MIN;
for (int i = 1; i <= n; i++) {
if (a[i] > a[u]) u = i;
}
int v = 0;
a[0] = INT_MAX;
for (int i = 1; i <= n; i++) {
if (a[i] < a[v]) v = i;
}
if (u > v) {
for (int i = 1; i <= n; i++) {
answer(i, n - a[u] + a[i]);
}
} else {
for (int i = 1; i <= n; i++) {
answer(i, (n + 1) - (n - a[u] + a[i]));
}
}
}
/*int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
solve();
}*/