#include<iostream> #include<algorithm> #include<vector> using namespace std; int main() { int n; cin >> n; vector<int>deg(n); for (int i = 0; i < n; ++i) cin >> deg[i]; sort(deg.begin(), deg.end()); int res = 2; if (deg[0] == 1) { --res; if (deg[1] == 1) --res; } cout << res << "\n2\n1 2"; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include<iostream> #include<algorithm> #include<vector> using namespace std; int main() { int n; cin >> n; vector<int>deg(n); for (int i = 0; i < n; ++i) cin >> deg[i]; sort(deg.begin(), deg.end()); int res = 2; if (deg[0] == 1) { --res; if (deg[1] == 1) --res; } cout << res << "\n2\n1 2"; return 0; } |