#define R register #define ll long long #define cmax(a, b) ((a < b) ? b : a) #define cmin(a, b) ((a < b) ? a : b) #define sum(a, b, mod) ((a + b) % mod) #define openfile(x) freopen(#x ".in", "r", stdin), freopen(#x ".out", "w", stdout) constint MaxN = 2e5 + 10; int n; int a[MaxN], cnt[MaxN]; std::vector<int> vec; intmain() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]), ++cnt[a[i]]; int max = 0, num = 0; for (int i = 1; i <= n; i++) { if (max < cnt[a[i]]) max = cnt[a[i]], num = a[i]; } printf("%d\n", n - max); if (max == n) return0; vec.push_back(0); for (int i = 1; i <= n; i++) { if (a[i] == num) vec.push_back(i); } for (int i = 1; i < vec.size(); i++) { for (int j = vec[i] - 1; j > vec[i - 1]; j--) { if (a[j] > num) printf("%d %d %d\n", 2, j, j + 1); else printf("%d %d %d\n", 1, j, j + 1); } } if (vec[vec.size() - 1] < n) { for (int i = vec[vec.size() - 1] + 1; i <= n; i++) { if (a[i] > num) printf("%d %d %d\n", 2, i, i - 1); else printf("%d %d %d\n", 1, i, i - 1); } } return0; }
#include<bits/stdc++.h> #define R register #define ll long long #define cmax(a, b) ((a < b) ? b : a) #define cmin(a, b) ((a < b) ? a : b) #define sum(a, b, mod) ((a + b) % mod) #define openfile(x) freopen(#x ".in", "r", stdin), freopen(#x ".out", "w", stdout) constint MaxN = 500010; structedge { int to, next; }; edge e[MaxN]; int n, m, cnt; int head[MaxN], col[MaxN], u[MaxN], v[MaxN]; inlinevoidadd_edge(int u, int v) { ++cnt; e[cnt].to = v; e[cnt].next = head[u]; head[u] = cnt; } inlineintread() { int x = 0; char ch = getchar(); while (ch > '9' || ch < '0') ch = getchar(); while (ch <= '9' && ch >= '0') x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar(); return x; } inlinevoiddfs(int u, int c) { col[u] = c; for (int i = head[u]; i; i = e[i].next) { int v = e[i].to; if (col[v]) continue; dfs(v, (c == 1) ? 2 : 1); } } intmain() { n = read(), m = read(); for (int i = 1; i <= m; i++) { u[i] = read(), v[i] = read(); add_edge(u[i], v[i]); add_edge(v[i], u[i]); } for (int i = 1; i <= n; i++) if (!col[i]) dfs(i, 1); for (int i = 1; i <= m; i++) { if (col[u[i]] == col[v[i]]) return0 * printf("NO"); } printf("YES\n"); for (int i = 1; i <= m; i++) { if (col[u[i]] == 1) printf("1"); else printf("0"); } return0; }