
#include <bits/stdc++.h>
#include "partition.h"
//#include "grader.cpp"
using namespace std;

typedef long long ll;

unordered_map<int,vector<int>> mp;

vector<int> solve(vector<int> a) {
    mp.clear();
    int n = a.size();

    for(int i = 0; i < n; i ++ )mp[a[i]].push_back(i);
    vector<int> b;
    for(auto [x, y] : mp) {
        for(int &i : y)b.push_back(i);
    }

    vector<int> out;
    for(int r = 0 + (n%2==0); r < n; r += 2)
        out.push_back(b[r]);

    for(int r = n-2; r >= 0; r -= 2)
        out.push_back(b[r]);
//    cout << ans << '\n';
    return out;
}
