# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
650486 | Koful123 | 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>
#include <xylophone.h>
using namespace std;
void solve(int n){
vector<int> v(n+1),th(n+1),se(n+1);
for(int i=1;i<=n;i++){
se[i] = query(i-1,i);
if(i != 1) th[i] = query(i-2,i);
}
for(int i=1;i<=n;i++){
int ok = 1; v[1] = i;
for(int j=2;j<=n;j++){
if(th[i] == se[i-1]){
v[i] = v[i-1] + (v[i-2] > v[i-1] ? se[i] : -se[i]);
}
else{
if(v[i-2] > v[i-1]){
if(se[i] == th[i]) v[i] = v[i-1] + se[i];
else v[i] = v[i-1] - se[i];
}
else{
if(th[i] == se[i]) v[i] = v[i-1] - se[i];
else v[i] = v[i-1] + se[i];;
}
}
if(vis[v[i]]){
ok = 0;
break;
}
}
if(!ok) continue;
for(int i=1;i<=n;i++){
answer(i,v[i]);
}
}
}