#include "triangles.h"
#pragma gcc optimize("Ofast")
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <random>
#include <bitset>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;
vector<vector<int>> solve(int n) {
    // Example of compare:
    // Пример использования функции compare:
    // std::vector<Triangle> left = {Triangle(0, 1, 2)};
    // std::vector<Triangle> right = {Triangle(0, 1, 2)};
    // int compare_result = compare(left, right);
    // // compare_result should be equal to 0.
    // // compare_result будет равняться нулю, так как сравнивались одинаковые треугольники.
    
    // // Example of return:
    // // Пример возвращаемого значения:
    // std::vector<std::vector<int>> ans;
    // ans.push_back(std::vector<int>(n));
    // for (int i = 0; i < n; ++i) {
    //     ans[0][i] = i;
    // }
    // return ans;
    int a = 0, b = 1;
    int c = 2;
    for (int i = 3; i < n; i++) {
        vector<Triangle> left = {Triangle(0, 1, c)};
        vector<Triangle> right = {Triangle(0, 1, i)};
        if (compare(left, right) == -1) {
            c = i;
        }
    }
    int other;
    for (int i = 0; i < n; i++) {
        if (i != c && i != b && i != a) {
            other = i;
        }
    }
    vector<Triangle> left = {Triangle(a, b, other), Triangle(b, c, other), Triangle(a, c, other)};
    vector<Triangle> right = {Triangle(a, b, c)};
    if (compare(left, right) == 0) {
        vector<vector<int>> ans = {{a, b, other}, {b, c, other}, {a, c, other}};
        return ans;
    } else {
        vector<Triangle> left = {Triangle(a, b, other), Triangle(a, b, c)};
        vector<Triangle> right = {Triangle(a, other, c), Triangle(b, c, other)};
        vector<vector<int>> ans;
        if (compare(left, right) == -1) ans = {{a, b, c}, {a, b, other}};
        else ans = {{a, b, c}, {a, b, other}};
        return ans;
    }
}
