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
#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, s;
    cin >> n >> s;

    bitset<50044> b;
    bitset<50044> act;
    
    for (int i = 0; i < s; i++) {
        int a;
        cin >> a;
        b[a] = 1;
    }

    int cnt = n;
    vector<tuple<int,int,int>> events;
    for (int i = 1; i <= n; i++) {
        bitset<50044> current;
        for (int j = i; j <= n; j += i) {
            current[j] = 1;
        }
        if (b[i] == 1 && act[i] == 0) {
            act |= current;
            events.push_back({1, i, cnt});
            cnt++;
        }
        else if (b[i] == 0 && act[i] == 1) {
            events.push_back({3, i, -1});
            cnt++;
            events.push_back({2, cnt - 1, cnt});
            cnt++;
            act &= ~current;
        }
    }

    cout << events.size() << "\n";
    for (auto [c, a, b]: events) {
        if (c == 3) {

            cout << c << " " << a << "\n";
        }else { 
            cout << c << " " << a << " " << b << "\n";
        }
    }
}