#include <iostream> #include <algorithm> void wypiszProsteDrzewo() { std::cout << "2\n1 2" << std::endl; } int main() { int n; std::cin >> n; int ileJedynek = 0; for (int i = 0; i < n; ++i) { int liczba; std::cin >> liczba; if (liczba == 1) ++ileJedynek; } int ileTrzebaZmienic = 2 - std::min(ileJedynek, 2); std::cout << ileTrzebaZmienic << std::endl; wypiszProsteDrzewo(); 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 | #include <iostream> #include <algorithm> void wypiszProsteDrzewo() { std::cout << "2\n1 2" << std::endl; } int main() { int n; std::cin >> n; int ileJedynek = 0; for (int i = 0; i < n; ++i) { int liczba; std::cin >> liczba; if (liczba == 1) ++ileJedynek; } int ileTrzebaZmienic = 2 - std::min(ileJedynek, 2); std::cout << ileTrzebaZmienic << std::endl; wypiszProsteDrzewo(); return 0; } |