#include<bits/stdc++.h> using namespace std; #define FOR(i, a, b) for(int i = a; i <= b; i++) #define REP(i, a) FOR(i, 0, a - 1) #define ST first #define ND second #define V vector #define RS resize #define EB emplace_back #define ALL(a) a.begin(), a.end() #define S(a) (int)a.size() template<class T> void db(T a) { cerr << a; } template<class L, class R> void db(pair<L, L> a) { cerr << "(" << a.ST << ", " << a.ND << ")"; } template<class T> void db(V<T> v) { cerr << "{"; REP(i, S(v)) cerr << (i != 0 ? ", " : ""), db(v[i]); cerr << "}"; } template<class T> void dump(const char *s, T a) { cerr << s << ": "; db(a); cerr << "\n"; } template<class T, class... TS> void dump(const char *s, T a, TS... x) { while(*s != ',') cerr<< *s++; cerr << ": "; db(a); dump(s + 1, x...); } #ifdef DEBUG #define DB(...) dump(#__VA_ARGS__, __VA_ARGS__); #else #define DB(...) #endif using LL = long long; using PII = pair<int, int>; using VI = V<int>; using VLL = V<LL>; using VVI = V<VI>; using VPII = V<PII>; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, ans = 2, a; cin >> n; REP(i, n) { cin >> a; if(a == 1 && ans != 0) ans--; } cout << ans << "\n2\n1 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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #include<bits/stdc++.h> using namespace std; #define FOR(i, a, b) for(int i = a; i <= b; i++) #define REP(i, a) FOR(i, 0, a - 1) #define ST first #define ND second #define V vector #define RS resize #define EB emplace_back #define ALL(a) a.begin(), a.end() #define S(a) (int)a.size() template<class T> void db(T a) { cerr << a; } template<class L, class R> void db(pair<L, L> a) { cerr << "(" << a.ST << ", " << a.ND << ")"; } template<class T> void db(V<T> v) { cerr << "{"; REP(i, S(v)) cerr << (i != 0 ? ", " : ""), db(v[i]); cerr << "}"; } template<class T> void dump(const char *s, T a) { cerr << s << ": "; db(a); cerr << "\n"; } template<class T, class... TS> void dump(const char *s, T a, TS... x) { while(*s != ',') cerr<< *s++; cerr << ": "; db(a); dump(s + 1, x...); } #ifdef DEBUG #define DB(...) dump(#__VA_ARGS__, __VA_ARGS__); #else #define DB(...) #endif using LL = long long; using PII = pair<int, int>; using VI = V<int>; using VLL = V<LL>; using VVI = V<VI>; using VPII = V<PII>; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, ans = 2, a; cin >> n; REP(i, n) { cin >> a; if(a == 1 && ans != 0) ans--; } cout << ans << "\n2\n1 2\n"; } |