#include <bits/stdc++.h>
using namespace std;
struct operation
{
int t, x, y;
};
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, s;
cin >> n >> s;
bitset<50001> target;
for (int i = 0; i < s; ++i)
{
int b;
cin >> b;
target[b] = true;
}
vector<operation> operations;
for (int i = 1; i <= n; ++i)
{
if (target[i])
{
operation o;
o.t = 1;
o.x = i;
o.y = n + operations.size();
operations.push_back(o);
}
else
{
operation o;
o.t = 3;
o.x = i;
operations.push_back(o);
o.t = 2;
o.x = n + operations.size() - 1;
o.y = n + operations.size();
operations.push_back(o);
}
}
cout << operations.size() << '\n';
for (auto [t, x, y] : operations)
{
cout << t << ' ' << x;
if (t != 3) cout << ' ' << y;
cout << '\n';
}
}
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 55 56 57 58 59 60 | #include <bits/stdc++.h> using namespace std; struct operation { int t, x, y; }; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, s; cin >> n >> s; bitset<50001> target; for (int i = 0; i < s; ++i) { int b; cin >> b; target[b] = true; } vector<operation> operations; for (int i = 1; i <= n; ++i) { if (target[i]) { operation o; o.t = 1; o.x = i; o.y = n + operations.size(); operations.push_back(o); } else { operation o; o.t = 3; o.x = i; operations.push_back(o); o.t = 2; o.x = n + operations.size() - 1; o.y = n + operations.size(); operations.push_back(o); } } cout << operations.size() << '\n'; for (auto [t, x, y] : operations) { cout << t << ' ' << x; if (t != 3) cout << ' ' << y; cout << '\n'; } } |
English