#include <cstdio> int main(int argc, char const *argv[]) { int n; scanf ("%d",&n); int v[n]; for (int i = 0; i < n; ++i) { scanf ("%d",&v[i]); } int ones_counter = 0; for (int i = 0; i < n; ++i) { if (v[i] == 1) { ones_counter++; } if (ones_counter > 2) { break; } } int to_change = 0; if (ones_counter < 2) { to_change = 2 - ones_counter; } printf("%d\n", to_change); printf("2\n"); printf("1 2\n"); 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 | #include <cstdio> int main(int argc, char const *argv[]) { int n; scanf ("%d",&n); int v[n]; for (int i = 0; i < n; ++i) { scanf ("%d",&v[i]); } int ones_counter = 0; for (int i = 0; i < n; ++i) { if (v[i] == 1) { ones_counter++; } if (ones_counter > 2) { break; } } int to_change = 0; if (ones_counter < 2) { to_change = 2 - ones_counter; } printf("%d\n", to_change); printf("2\n"); printf("1 2\n"); return 0; } |