#include<iostream> using namespace std; int main(){ int n,s=0; cin >> n; int q; for(int i = 0;i < n;i++){ cin >> q; if(q == 1)s++; } if(s >= 2){ cout <<'0'<<'\n'<<'2'<<'\n'<<'1'<<" "<<'2'; } else if(s==1) cout<<1<<'\n'<<'2'<<'\n'<<'1'<<" "<<'2'; else cout << 2 <<'\n'<<'2'<<'\n'<<'1'<<" "<<'2'; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #include<iostream> using namespace std; int main(){ int n,s=0; cin >> n; int q; for(int i = 0;i < n;i++){ cin >> q; if(q == 1)s++; } if(s >= 2){ cout <<'0'<<'\n'<<'2'<<'\n'<<'1'<<" "<<'2'; } else if(s==1) cout<<1<<'\n'<<'2'<<'\n'<<'1'<<" "<<'2'; else cout << 2 <<'\n'<<'2'<<'\n'<<'1'<<" "<<'2'; } |