#include<bits/stdc++.h>
#include "partition.h"
#define endl "\n"
using namespace std;
void speed()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

bool cmp(pair<int, int> x, pair<int, int> y)
{
    return x.first < y.first;
}
vector<int> solve(vector<int> A)
{
    int n = A.size();
    vector<pair<int, int>> a(n);
    for(int i = 0; i < n; ++i)
    {
        a[i].first = A[i];
        a[i].second = i;
    }
    sort(a.begin(), a.end(), cmp);
    vector<bool> used(n, false);
    vector<int> ans(n, -1);
    int newn = n / 2;
    for(int i = 0; i < newn - 1; i++)
    {
        ans[i] = a[i].second;
        a[i].second = -1;
        used[i] = true;
    }
    ans[newn - 1] = a[n-1].second;
    a[n-1].second = -1;
    used[newn - 1] = true;
    for(int i = 0; i < n-1; i++)
    {
        if(used[i] == false)
        {
            ans[i] = a[i].second;
            a[i].second = -1;
            used[i] = true;
        }
    }
    for(int i = 0; i < n; i++)
    {
        if(a[i].second != -1)
        {
            ans[n-1] = a[i].second;
        }
    }
    return ans;
}

