#include <cstdio>
#include <string>
#include <vector>
using namespace std;
#define N 50005
bool b[N];
int main() {
int n, s;
vector<string> result;
scanf("%d %d", &n, &s);
for (int i = 0; i < s; i++) {
int bi;
scanf("%d", &bi);
b[bi] = true;
}
bool found = false;
int last = -1;
for (int i = 1; i <= n; i++) {
if (b[i]) {
if (!found) {
found = true;
if (i == n) break;
last = i;
}
else {
result.push_back("1 " + to_string(last) + " " + to_string(i));
last = n + result.size();
}
}
else {
if (found) {
result.push_back("3 " + to_string(i));
result.push_back("2 " + to_string(last) + " " + to_string(n + result.size()));
last = n + result.size();
}
}
}
printf("%lld\n", result.size());
for (auto it = result.begin(); it != result.end(); ++it) {
printf("%s\n", it->c_str());
}
return 0;
}
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 | #include <cstdio> #include <string> #include <vector> using namespace std; #define N 50005 bool b[N]; int main() { int n, s; vector<string> result; scanf("%d %d", &n, &s); for (int i = 0; i < s; i++) { int bi; scanf("%d", &bi); b[bi] = true; } bool found = false; int last = -1; for (int i = 1; i <= n; i++) { if (b[i]) { if (!found) { found = true; if (i == n) break; last = i; } else { result.push_back("1 " + to_string(last) + " " + to_string(i)); last = n + result.size(); } } else { if (found) { result.push_back("3 " + to_string(i)); result.push_back("2 " + to_string(last) + " " + to_string(n + result.size())); last = n + result.size(); } } } printf("%lld\n", result.size()); for (auto it = result.begin(); it != result.end(); ++it) { printf("%s\n", it->c_str()); } return 0; } |
English