// // Created by cyryl on 10.12.18. // #include <iostream> #include <algorithm> bool myComp(int lhs, int rhs) { return rhs < lhs; } int main() { int n; std::cin>>n; int deg[n]; for (int i = 0; i < n; i++) std::cin>>deg[i]; std::make_heap(deg, deg + n, myComp); int changes = 0; if (deg[0] > 1) changes++; std::pop_heap(deg, deg + n, myComp); if (deg[0] > 1) changes++; std::cout<<changes<<"\n"; std::cout<<2<<"\n"; std::cout<<1<<" "<<2<<"\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 | // // Created by cyryl on 10.12.18. // #include <iostream> #include <algorithm> bool myComp(int lhs, int rhs) { return rhs < lhs; } int main() { int n; std::cin>>n; int deg[n]; for (int i = 0; i < n; i++) std::cin>>deg[i]; std::make_heap(deg, deg + n, myComp); int changes = 0; if (deg[0] > 1) changes++; std::pop_heap(deg, deg + n, myComp); if (deg[0] > 1) changes++; std::cout<<changes<<"\n"; std::cout<<2<<"\n"; std::cout<<1<<" "<<2<<"\n"; } |