#include "triangles.h"

#include <bits/stdc++.h>

using namespace std;

std::vector<std::vector<int> > solve(int n) {
    vector<int> ord(n);
    iota(ord.begin(), ord.end(), 0);
    do {
        vector<Triangle> left, right;
        left = {Triangle(ord[0], ord[1], ord[2]), Triangle(ord[2], ord[3], ord[0])};
        right = {Triangle(ord[1], ord[2], ord[3]), Triangle(ord[3], ord[0], ord[1])};
        if (compare(left, right) == 0) {
            vector<vector<int> > ans;
            ans = {{ord[0], ord[1], ord[2]}, {ord[2], ord[3], ord[0]}};
            return ans;
            break;
        }
    } while (next_permutation(ord.begin(), ord.end()));
    vector<int> bigger = {0, 1, 2};
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                vector<int> cur = {i, j, k};
                vector<Triangle> left, right;
                left.emplace_back(Triangle(bigger[0], bigger[1], bigger[2]));
                right.emplace_back(Triangle(cur[0], cur[1], cur[2]));
                if (compare(left, right) == -1)
                    bigger = cur;
            }
        }
    }
    vector<vector<int> > ans;
    int remain = 0 + 1 + 2 + 3;
    for (int i: bigger) remain -= i;
    ans.emplace_back(vector<int>{bigger[0], bigger[1], remain});
    ans.emplace_back(vector<int>{bigger[1], bigger[2], remain});
    ans.emplace_back(vector<int>{bigger[2], bigger[0], remain});
    return ans;
}
