#include <algorithm>
#include "triangles.h"

std::vector<std::vector<int>> solve(int n) {
    vector<vector<int>> t;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            for (int k = j + 1; k < n; ++k) {
                t.push_back({i, j, k});
            }
        }
    }
    std::sort(t.begin(), t.end(), [&](const vector<int>& a, const vector<int>& b) {
        int pon = compare({Triangle(a[0], a[1], a[2])}, {Triangle(b[0], b[1], b[2])});
        return pon == 1;
    });
    vector<vector<int>> ans;
    ans.push_back(t[0]);
    for (int i = 1; i < n; ++i) {
        int cnt = 0;
        for (int j = 0; j < 3; ++j) {
            if (ans[0][j] == t[i][j]) {
                cnt++;
            }
        }
        if (cnt >= 2) {
            ans.push_back(t[i]);
            break;
        }
    }
    return ans;
} 
