#include <bits/stdc++.h> #define F first #define S second #define ll long long #define ld long double #define vi vector < int > #define vll vector < ll > #define pb push_back #define sz(x) int((x).size()) #define pii pair < int, int > #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define vpii vector < pii > #define sqr(x) ((x)*(x)) #define fenwick(x) ((x) & -(x)) #define debug(x) cout << "[ " << #x << " ]: " << x << "\n"; using namespace std; //CZY DANE POSORTOWANE, N = 0, N = 1, CZYTANIE TRESCI, < rosnaco, > malejaco int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N; cin >> N; int jedynki = 0; for (int i = 0, a; i < N; ++i) { cin >> a; if (a == 1)jedynki++; } if (jedynki >= 2) { cout << 0 << "\n" << 2 << "\n" << 1 << " " << 2 << "\n"; } else if (jedynki == 1) { cout << 1 << "\n" << 2 << "\n" << 1 << " " << 2 << "\n"; } else if (jedynki == 0) { cout << 2 << "\n" << 2 << "\n" << 1 << " " << 2 << "\n"; } 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | #include <bits/stdc++.h> #define F first #define S second #define ll long long #define ld long double #define vi vector < int > #define vll vector < ll > #define pb push_back #define sz(x) int((x).size()) #define pii pair < int, int > #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define vpii vector < pii > #define sqr(x) ((x)*(x)) #define fenwick(x) ((x) & -(x)) #define debug(x) cout << "[ " << #x << " ]: " << x << "\n"; using namespace std; //CZY DANE POSORTOWANE, N = 0, N = 1, CZYTANIE TRESCI, < rosnaco, > malejaco int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N; cin >> N; int jedynki = 0; for (int i = 0, a; i < N; ++i) { cin >> a; if (a == 1)jedynki++; } if (jedynki >= 2) { cout << 0 << "\n" << 2 << "\n" << 1 << " " << 2 << "\n"; } else if (jedynki == 1) { cout << 1 << "\n" << 2 << "\n" << 1 << " " << 2 << "\n"; } else if (jedynki == 0) { cout << 2 << "\n" << 2 << "\n" << 1 << " " << 2 << "\n"; } return 0; } |