#include "art.h"
#include <bits/stdc++.h>
using namespace std;
//
// --- Sample implementation for the task art ---
//
// To compile this program with the sample grader, place:
// art.h art_sample.cpp sample_grader.cpp
// in a single folder, then open the terminal in this directory (right-click onto an empty spot in the directory,
// left click on "Open in terminal") and enter e.g.:
// g++ -std=c++17 art_sample.cpp sample_grader.cpp
// in this folder. This will create a file a.out in the current directory which you can execute from the terminal
// as ./a.out
// See task statement or sample_grader.cpp for the input specification
//
int query(vector<int> x) {
reverse(x.begin(), x.end());
return publish(x);
}
void ans(vector<int> x) {
reverse(x.begin(), x.end());
answer(x);
}
vector<int> rotate(vector<int> x) {
vector<int> y; y.push_back(x.back());
for (int i = 0; i < (int)x.size() - 1; i++) y.push_back(x[i]);
return y;
}
void solve(int N) {
vector<int> perm;
for (int i = 1; i <= N; i++) perm.push_back(i);
int prev = query(perm); vector<int> index(N + 1);
int init = prev;
int done = 0;
while (done != N) {
if (done == N - 1) {
int cur = init;
int lst = perm.back();
index[lst] = ((cur-prev) + N - 1)/2;
break;
}
int lst = perm.back();
vector<int> perm2 = rotate(perm);
int cur = query(perm2);
index[lst] = ((cur-prev) + N - 1)/2;
done++;
prev = cur;
perm = perm2;
}
vector<int> fin(N);
for (int i = 1; i <= N; i++) fin[index[i]] = i;
ans(fin);
}
// g++ -std=c++17 art_sample.cpp sample_grader.cpp
/*
10
1 5 2 3 8 7 6 9 4 10
*/