#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
//
vector <int> dop(vector <int> pre , vector <int> S , int N)
{
vector <int> res;
for(auto p : pre)res.push_back(p);
for(auto p : S)res.push_back(p);
for(int i = pre.size()+S.size()+1 ; i <= N ; i++)res.push_back(i);
return res;
}
void solve(int N)
{
vector <int> L = {1};
int aktI = publish(dop({},L,N));
for(int i = 2; i <= N ; i++)
{
int y = publish(dop({i},L,N));
int ilem = (y-aktI+(i-1))/2;
vector <int> temp;
while(temp.size() < ilem)
{
int ra = temp.size();
temp.push_back(L[ra]);
}
int ra = temp.size();
temp.push_back(i);
for(; ra < i-1 ; ra++)temp.push_back(L[ra]);
L = temp;
aktI = y-ilem;
}
answer(L);
}