#include "triangles.h"

using namespace std;

std::vector<std::vector<int>> solve(int n) {
    vector<vector<int>> ans;
    vector<bool> ban(n);
    while (true) {
        vector<Triangle> cur;
        bool ok = false;
        for (int i = 0; i < n; ++i) {
            for (int j = i + 1; j < n; ++j) {
                for (int k = j + 1; k < n; ++k) {
                    if (!ban[i] || !ban[j] || !ban[k]) {
                        cur = {Triangle(i, j, k)};
                        ok = true;
                        break;
                    }
                }
                if (ok) {
                    break;
                }
            }
            if (ok) {
                break;
            }
        }
        if (!ok) {
            break;
        }
        for (int i = 0; i < n; ++i) {
            for (int j = i + 1; j < n; ++j) {
                for (int k = j + 1; k < n; ++k) {
                    if (!ban[i] || !ban[j] || !ban[k]) {
                        vector<Triangle> a = {Triangle(i, j, k)};
                        if (compare(cur, a) == 1) {
                            cur = a;
                        }
                    }
                }
            }
        }
        ans.push_back({cur[0].i, cur[0].j, cur[0].k});
        ban[cur[0].i] = 1;
        ban[cur[0].j] = 1;
        ban[cur[0].k] = 1;
    }
    return ans;
}
