#include "partition.h"
#include "map"

std::vector<int> solve(std::vector<int> A) {
    std::map<int,int> vf;
    int st = 0,dr = A.size()-1;

    std::vector<int> rez(A.size());

    for (int i=0; i<A.size(); i++) {
        if (vf[A[i]]%2 == 0) {
            rez[dr--] = i;
        }
        else {
            rez[st++] = i;
        }
        vf[A[i]] ++;
    }

    return rez;
}