#include "partition.h"
#include <algorithm>
#include <iostream>
std::vector<int> solve(std::vector<int> A) {
    int s=0;
    std::vector<int>v;
    int n=0;
    for(int i=0;i<A.size();i++){
        int e=A[i];
        v.push_back(e);
        n++;
        s+=e;
    }
    if(n==1) return {0};
    if(n==2) return {1,0};
    if(n==3) return {2,1,0};
    std::vector<int>a;
    for(int i=0;i<n;i++){
        a.push_back(0);
    }
    int i1=0,i2=n-1;
    int idx=0;
    for(int i=n-1;i>0;i-=4){
        if(i>=3){
            a[i1++]=i;
            a[i1++]=i-3;
            a[i2--]=i-1;
            a[i2--]=i-2;
            idx=i-3;
        }
    }
    if(idx==1) a[i1++]=0;
    if(idx==2) a[i1++]=1,a[i2--]=0;
    if(idx==3) a[i1++]=2,a[i2--]=1,a[i2--]=0;
    return a;
}
