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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <vector>
#include <tuple>

using namespace std;

void apply_sum(vector<bool> &current, int num) {
    for (int i = num; i <= current.size(); i += num)
        current[i] = true;
}

void apply_difference(vector<bool> &current, int num) {
    for (int i = num; i <= current.size(); i += num)
        current[i] = false;
}

int main() {
    int n, s, first;
    cin >> n >> s;
    
    vector<bool> goal(n+1, false);
    for (int i = 0; i < s; i++) {
        int existing;
        cin >> existing;
        goal[existing] = true;
        if (i == 0) {
            first = existing;
        }
    }
    vector<bool> current(n+1, false);
    vector<tuple<int, int, int>> operations;
    operations.emplace_back(1, first, first);
    apply_sum(current, first);
    for (int i = 1; i <= n; i++) {
        if (goal[i] && !current[i]) {
            operations.emplace_back(1, n + operations.size(), i);
            apply_sum(current, i);
        }
        if (!goal[i] && current[i]) {
            operations.emplace_back(3, i, -1);
            operations.emplace_back(2, n + operations.size(), n - 1 + operations.size());
            apply_difference(current, i);
        }
    }
    cout << operations.size() << endl;
    for (auto [type, a, b] : operations) {
        if (type == 3) {
            cout << type << " " << a << endl;
        } else {
            cout << type << " " << a << " " << b << endl;
        }
    }
    return 0;
}