#include "triangles.h"

#include <algorithm>
using namespace std;

vector<vector<int>> solve(int n) {
    Triangle res = {0, 1, 2};
    vector<vector<int>> ans = {{0, 1, 2}};
    for (int i = 3; i < n; i++) {
        Triangle a = {i, res.j, res.k};
        Triangle b = {res.i, i, res.k};
        Triangle c = {res.i, res.j, i};

        int chosen = -1;
        if (compare({a}, {res}) == 1) {
            res = a;
            chosen = 1;
        }
        if (compare({b}, {res}) == 1) {
            res = b;
            chosen = 2;
        }
        if (compare({c}, {res}) == 3) {
            res = c;
            chosen = 3;
        }
        if (chosen == 1) {
            ans.push_back({i, res.i, res.j});
            ans.push_back({i, res.i, res.k});
        }
    }
    return ans;
}
