#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
template<class T, class U>
ostream& operator<<(ostream& os, pair<T, U> p) {
return os << "(" << p.first << ", " << p.second << ")";
}
template<class C, class = typename C::value_type>
typename enable_if<!is_same<C, string>::value, ostream&>::type
operator<<(ostream& os, C c) {
for (auto i = c.begin(); i != c.end(); i++) {
os << " {"[i == c.begin()] << *i << ",}"[next(i) == c.end()];
}
return os;
}
#define debug(x) { cerr << #x << " = " << x << endl; }
#else
#define debug(...) {}
#endif
void answer(int x) {
cout << x << "\n";
cout << "2\n";
cout << "1 2\n";
}
int main() {
int n;
cin >> n;
vector<int> in;
int one_count = 0;
for (int i = 0; i < n; i ++) {
int x;
cin >> x;
in.push_back(x);
if (x == 1) one_count ++;
}
if (one_count >= 2) {
answer(0);
} else if (one_count == 1) {
answer(1);
} else if (one_count == 0) {
answer(2);
}
}
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #include <bits/stdc++.h> using namespace std; #ifdef LOCAL template<class T, class U> ostream& operator<<(ostream& os, pair<T, U> p) { return os << "(" << p.first << ", " << p.second << ")"; } template<class C, class = typename C::value_type> typename enable_if<!is_same<C, string>::value, ostream&>::type operator<<(ostream& os, C c) { for (auto i = c.begin(); i != c.end(); i++) { os << " {"[i == c.begin()] << *i << ",}"[next(i) == c.end()]; } return os; } #define debug(x) { cerr << #x << " = " << x << endl; } #else #define debug(...) {} #endif void answer(int x) { cout << x << "\n"; cout << "2\n"; cout << "1 2\n"; } int main() { int n; cin >> n; vector<int> in; int one_count = 0; for (int i = 0; i < n; i ++) { int x; cin >> x; in.push_back(x); if (x == 1) one_count ++; } if (one_count >= 2) { answer(0); } else if (one_count == 1) { answer(1); } else if (one_count == 0) { answer(2); } } |
English