1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <vector>

int main() {
    int32_t n, s;
    std::cin >> n >> s;
    std::vector<bool> target(n, false);
    for (int32_t i = 0; i < s; ++i) {
        int32_t b;
        std::cin >> b;
        target[b - 1] = true;
    }

    std::vector<std::string> ops;
    int32_t current_set = 0;
    for (int32_t i = 1; i <= n; ++i) {
        int32_t next_set = n + ops.size() + 1;
        if (current_set == 0 && target[i - 1]) {
            current_set = i;
        } else if (current_set > 0 && target[i - 1]) {
            ops.push_back(std::string("1 ") + std::to_string(current_set) + " " + std::to_string(i));
            current_set = next_set;
        } else if (current_set > 0 && !target[i - 1]) {
            ops.push_back(std::string("3 ") + std::to_string(i));
            ops.push_back(std::string("2 ") + std::to_string(current_set) + " " + std::to_string(next_set));
            current_set = next_set + 1;
        }
    }

    if (current_set < n) {
        ops.push_back(std::string("1 ") + std::to_string(current_set) + " " + std::to_string(current_set));
    }

    std::cout << ops.size() << "\n";
    for (auto &op: ops) {
        std::cout << op << "\n";
    }
}