# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1114439 | sunboi | 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.
#include <bits/stdc++.h>
using namespace std;
void solve(int n){
return;
int pos = 0;
int i = 1;
while(query(i, n) == n - 1){
i++;
}
i--;
int reference = i;
vector<int> ans(n);
int x = query(i, i + 1) + 1;
ans[i] = 1;
ans[i + 1] = x;
i += 2;
for (i; i <= n; i++){
int mn = min(a[i - 1], a[i - 2]);
int mx = max(a[i - 1], a[i - 2]);
int uno = query(i - 1, i);
int dos = query(i - 2, i);
if (dos > uno){
if (a[i - 1] + uno == a[i - 2] + dos){
a[i] = a[i - 1] + uno;
}else{
a[i] = a[i - 1] - uno;
}
}else{
if (a[i - 1] == mn) a[i] = a[i - 1] + uno;
else a[i] = a[i - 1] - uno;
}
}
i = reference;
x = query(i - 1, i);
ans[i - 1] = 1 + x;
i -= 2;
for (i; i >= 1; i--){
int mn = min(a[i + 1], a[i + 2]);
int mx = max(a[i + 1], a[i + 2]);
int uno = query(i + 1, i);
int dos = query(i + 2, i);
if (dos > uno){
if (a[i + 1] + uno == a[i + 2] + dos){
a[i] = a[i + 1] + uno;
}else{
a[i] = a[i + 1] - uno;
}
}else{
if (a[i + 1] == mn) a[i] = a[i + 1] + uno;
else a[i] = a[i + 1] - uno;
}
}
for (int i = 1; i <= n; i++) answer(i, a[i]);
}