text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; int main() { int n, a = 0, b = 0; cin >> n; string s; cin >> s; for (int i = 0; i < n; i++) { if (s[i] == '0') { a++; } else b++; } if (a == b) cout << 2 << endl << s.substr(0, n - 1) << " " << s[n - 1]; else cout << 1 << endl << s; return 0; }
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; string s; cin >> s; int one = 0, zero = 0; for (int i = 0; i < n; i++) { if (s[i] == '1') one++; else zero++; } if (one != zero) { cout << 1 << endl; cout << s << endl; } else { cout << 2 << endl; cout << s[0] << " " << s.substr(1, (int)s.size() - 1); } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; t = 1; while (t--) { solve(); } }
#include <bits/stdc++.h> using namespace std; int n, cnt1[2], cnt2[2]; int main() { string str; cin >> n >> str; for (int p = 0; p < str.length(); p++) cnt1[str[p] - '0']++; if (str.length() == 1 || cnt1[0] == str.length() || cnt1[1] == str.length() || cnt1[0] != cnt1[1]) { cout << 1 << "\n" << str; return 0; } cnt1[0] = cnt1[1] = 0; cout << 2 << "\n"; int i; for (i = 0; i < str.length(); i++) { cnt1[str[i] - '0']++; for (int j = i + 1; j < str.length(); j++) { cnt2[str[j] - '0']++; } if ((cnt1[0] != cnt1[1]) && (cnt2[0] != cnt2[1])) { for (int k = 0; k <= i; k++) cout << str[k]; cout << " "; for (int k = i + 1; k < str.length(); k++) cout << str[k]; cout << "\n"; return 0; } memset(cnt2, 0, sizeof(cnt2)); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, sum = 0; string s; cin >> n >> s; for (int i = 0; i < n; i++) { if (s[i] == '0') sum = sum - 1; else sum++; } if (sum != 0) { cout << 1 << endl << s; } else { cout << 2 << endl << s[0] << " "; if (n > 1) cout << s.substr(1); } return 0; }
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int n; cin >> n; string s; cin >> s; int l = s.size(); int zero = 0, one = 0; for (int i = 0; i < l; i++) { if (s[i] == '0') zero++; else one++; } if (zero != one) { cout << 1 << endl; cout << s << endl; } else { cout << 2 << endl; cout << s[0] << " " << s.substr(1, s.length() - 1) << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T a, T b) { if (a == 0) return b; return gcd(b % a, a); } vector<long long> b_v; void bin(unsigned long long n) { if (n > 1) bin(n >> 1); b_v.emplace_back(n & 1); } long long isPowerof2(long long x) { return (x && !(x & x - 1)); } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ostream_iterator<long long> output(cout, " "); long long n; cin >> n; string second; cin >> second; long long c0 = 0; long long c1 = 0; for (long long(i) = (0); i < (n); i++) { if (second[i] == '0') c0++; else c1++; } if (c0 != c1) { cout << 1 << '\n'; cout << second; } else { cout << 2 << '\n'; cout << second[0] << " "; for (long long(i) = (1); i < (n); i++) { cout << second[i]; } } return 0; }
#include <bits/stdc++.h> using namespace std; void recursive_reverse(string &s, int start, int end) { if (start >= end) return; char temp = s[start]; s[start] = s[end]; s[end] = temp; recursive_reverse(s, start + 1, end - 1); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int T = 1; while (T--) { int n; cin >> n; string s; cin >> s; int z = 0, o = 0; for (int i = 0; i < n; i++) { if (s[i] == '1') o++; else z++; } if (o != z) { cout << 1 << endl << s; } else { string p = s.substr(0, n - 1); cout << 2 << endl; string q = s.substr(n - 1, 1); cout << p << " " << q; } } }
#include <bits/stdc++.h> using namespace std; int main(void) { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; string input; cin >> input; int num = 0; for (int i = 0; i < n; i++) { if (input[i] == '0') num++; else num--; } if (num) cout << "1\n" << input << '\n'; else cout << "2\n" << input.substr(0, n - 1) << ' ' << input[n - 1] << '\n'; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int len; cin >> len; cin >> s; int cnt1 = 0, cnt2 = 0; for (int i = 0; i < len; i++) { if (s[i] == '1') cnt1++; else cnt2++; } if (cnt1 != cnt2) { cout << "1" << endl; cout << s << endl; } else { cout << "2" << endl; cout << s[0] << " "; for (int i = 1; i < len; i++) { cout << s[i]; } } return 0; }
#include <bits/stdc++.h> using namespace std; struct node { int z = 0, o = 0; }; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; string str; cin >> str; if (n == 1) { cout << 1 << "\n" << str; } else if (n == 2) { if (str[0] != str[1]) { cout << 2 << "\n" << str[0] << " " << str[1]; } else { cout << 1 << "\n" << str; } } else { node *dp = new node[n]; if (str[0] == '1') { dp[0].o++; } else { dp[0].z++; } for (int i = 1; i < n; i++) { if (str[i] == '1') { dp[i].o = dp[i - 1].o + 1; dp[i].z = dp[i - 1].z; } else { dp[i].z = dp[i - 1].z + 1; dp[i].o = dp[i - 1].o; } } int j = n - 1; while (dp[j].z == dp[j].o) { j--; } if (j == n - 1) { cout << 1 << "\n" << str; } else { string s1 = "", s2 = ""; for (int i = 0; i <= j; i++) { s1 += str[i]; } for (int i = j + 1; i < n; i++) { s2 += str[i]; } cout << 2 << "\n" << s1 << " " << s2; } delete[] dp; } }
#include <bits/stdc++.h> using namespace std; const long long INF = 1e17 + 5; const long long maxn = 1e5 + 5; long long n, m, a[maxn], b[maxn], ans, sum; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; cin >> n; string k; cin >> k; long long len = k.length(); for (long long i = 1; i <= len; i++) { if (k[i - 1] - '0') { a[1]++; } else a[0]++; } if (a[1] != a[0]) { cout << 1 << '\n' << k; return 0; } else { cout << 2 << '\n'; cout << k[0] << " "; for (long long i = 2; i <= len; i++) cout << k[i - 1]; } return 0; }
#include <bits/stdc++.h> using namespace std; long long MAX = 1000005; long long mod = 1e9 + 7; int main() { long long n; cin >> n; string s; cin >> s; long long flag = 0; for (long long i = 0; i < n; i = i + 1) { if (s[i] == '0') flag--; else flag++; } if (n == 1) { cout << 1 << endl; cout << s << endl; exit(0); } if (flag != 0) { cout << 1 << endl; cout << s << endl; } else { cout << 2 << endl; for (long long i = 0; i < n - 1; i = i + 1) cout << s[i]; cout << " "; cout << s[n - 1]; cout << endl; } }
#include <bits/stdc++.h> using namespace std; int n, x, y; string str; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n >> str; for (int i = 0; i < n; i++) { if (str[i] == '1') x++; else y++; } if (x == y) { cout << "2\n" << str[0] << " "; for (int i = 1; i < n; i++) cout << str[i]; } else cout << "1\n" << str; }
#include <bits/stdc++.h> int main(void) { int i, j, N, count1 = 0, count0 = 0; scanf("%d", &N); char str[N]; scanf("%s", str); for (i = 0; i < N; i++) { if (str[i] == '1') count1++; else if (str[i] == '0') count0++; } if (N != 1) { if (count1 != count0) { printf("1\n"); printf("%s", str); } else if (count0 == count1) { printf("2\n"); printf("%c ", str[0]); for (j = 1; j < N; j++) { printf("%c", str[j]); } } } else if (N == 1) { printf("1\n%s", str); } }
#include <bits/stdc++.h> using namespace std; bool same(string a) { int cnt1 = 0, cnt2 = 0; for (int i = 0; a[i]; i++) { if (a[i] == '1') cnt1++; else cnt2++; } return cnt1 == cnt2; } int main() { ios_base::sync_with_stdio(0), cin.tie(0); int n; cin >> n; string s; cin >> s; if (!same(s)) { cout << 1 << endl; cout << s; exit(0); } cout << 2 << endl; cout << s.substr(0, s.length() - 1) << " " << s[s.length() - 1]; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, i, j = 0, one = 0, zero = 0; cin >> n; char str[n + 1]; for (i = 0; i < n; i++) { cin >> str[i]; if (str[i] == '0') zero++; else one++; } str[n] = NULL; if (zero != one) { cout << 1 << endl; cout << str << endl; } else { cout << 2 << endl; cout << str[0] << " "; for (i = 1; i < n; i++) cout << str[i]; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, zero = 0, one = 0; cin >> n; string s; cin >> s; for (int i = 0; i < n; i++) { if (s[i] == '0') zero++; else one++; } if (zero != one) cout << "1\n" << s << endl; else { char temp = s[s.size() - 1]; s.erase(s.size() - 1); cout << "2\n" << s << " " << temp << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { bool a[100]; int n; int n1 = 0, n0 = 0; cin >> n; for (int i = 0; i < n; i++) { scanf("%1d", &a[i]); if (a[i]) n1++; else n0++; } if (n1 != n0) { cout << "1\n"; for (int i = 0; i < n; i++) cout << a[i]; } else { cout << "2\n"; cout << a[0] << ' '; for (int i = 1; i < n; i++) cout << a[i]; cout << ' '; } return 0; }
#include <bits/stdc++.h> using namespace std; string ent = "\n"; string space = " "; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; string s; cin >> s; int zero, one; zero = one = 0; for (int i = 0; i < n; i++) { if (s[i] == 48) zero++; else one++; } if (one != zero) { cout << 1 << ent + s + ent; } else { int j = n - 1; string s_new; for (int i = 0; i < n; i++) { if (one != zero) { j = i; break; } s_new += s[i]; if (s[i] == 48) zero--; else one--; } cout << 2 << ent + s_new + space; for (int i = j; i < n; i++) { cout << s[i]; } cout << ent; } }
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") using namespace std; void solve() { long long int n; cin >> n; string s; cin >> s; long long int cnt = 0; for (int(i) = (0); (i) < (n); ++(i)) { cnt += s[i] == '0'; } if (n == 2 * cnt) { cout << 2 << "\n"; cout << s[0] << " " << s.substr(1) << "\n"; } else { cout << 1 << "\n"; cout << s << "\n"; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int n; cin >> n >> s; int z = 0, o = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') z++; else o++; } if (z != o) cout << 1 << endl << s << endl; else { cout << 2 << endl; cout << s[0] << " "; for (int i = 1; i < s.size(); i++) cout << s[i]; cout << endl; } }
#include <bits/stdc++.h> using namespace std; const int N = 1e9; int main() { int n, one = 0, zero = 0, o = 0, z = 0; string s; cin >> n >> s; for (int i = 0; i < n; i++) { if (s[i] == '0') zero++; else one++; } if (one != zero) { cout << "1" << endl << s << endl; return 0; } z = zero; o = one; for (int i = 0; i < n; i++) { if (s[i] == '0') z--; else o--; if (zero - z == one - o) continue; else { string x = s.substr(0, i + 1), t = s.substr(i + 1, n); if (i != n - 1) cout << "2" << endl << x << " " << t << endl; return 0; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int one = 0, zero = 0; for (int i = 0; i < s.length(); i++) { if (s[i] == '0') zero++; else one++; } if (one != zero) { cout << 1 << endl; cout << s << endl; } else { cout << 2 << endl; cout << s[0] << " "; for (int i = 1; i < n; i++) cout << s[i]; cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const long long MAX1 = 3e5 + 10; long long a, b, c, d, e, cnt, x, y, l, r, flag, num[MAX1]; string s, t, st[MAX1]; char ch1, ch2; vector<long long> vec; int top(long long n, long long m) { if (n % m == 0) return n / m; return n / m + 1; } int main() { cin >> a; cin >> s; for (int i = 0; i < a; ++i) { if (s[i] == '0') ++x; else ++y; } if (x == y) { cout << "2\n" << s[0] << ' '; for (int i = 1; i < a; ++i) cout << s[i]; } else cout << 1 << '\n' << s; return 0; }
#include <bits/stdc++.h> using namespace std; const long double pi = acos(-1); void boos() { ios_base ::sync_with_stdio(false); cin.tie(0); cout.tie(0); } void file() { freopen("dales.in", "r", stdin); freopen("dales.out", "w", stdout); } const long long INF = 1e9 + 7; const long long INF1 = 998244353; const long long LLINF = (long long)1e15; const int INTmx = (int)1e9; const int N = 1e6 + 100; int main() { boos(); int n; cin >> n; string a; cin >> a; int kol = 0; for (int i = 0; i < a.size(); i++) { if (a[i] == '1') kol++; else kol--; } if (kol == 0) { cout << 2 << endl << a.substr(0, a.size() - 1) << " " << a.substr(a.size() - 1, 1); } else { cout << 1 << endl << a; } }
#include <bits/stdc++.h> int main() { int n, i, x = 0, y = 0; char a[101] = {0}; scanf("%d\n", &n); for (i = 0; i < n; i++) { scanf("%c", &a[i]); if (a[i] == '0') { x++; } else if (a[i] == '1') { y++; } } a[i] = '\0'; if (x != y) { printf("1\n%s\n", a); } else { printf("2\n"); for (i = 0; i < n - 1; i++) { printf("%c", a[i]); } printf(" %c\n", a[n - 1]); } return 0; }
#include <bits/stdc++.h> using namespace std; void shuru_krte_hai_bina_kisi_bakchodi_ke() { ios_base::sync_with_stdio(false); cin.tie(NULL); } const long long mod = 1e9 + 7; int main() { shuru_krte_hai_bina_kisi_bakchodi_ke(); int n; cin >> n; string s; cin >> s; int count0 = 0, count1 = 0; for (int i = 0; i < n; i++) { if (s[i] == '1') { count1++; } else { count0++; } } if (count1 != count0) { cout << 1 << "\n"; cout << s << "\n"; } else { cout << 2 << "\n"; cout << s[0] << " " << s.substr(1, n - 1) << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5, M = 3, nBits = 2e8 + 5, MM = (1 << 16), MAX = 1111, OO = 0x3f3f3f3f, MOD = 1000000007, inf = 1 << 30; const double PI = acos(-1); const long long INF = (long long)1e18, MOOD = 1000000007; long long GCD(long long a, long long b) { return !b ? a : GCD(b, a % b); } long long LCM(long long x, long long y) { return (x * y / GCD(x, y)); } long long fact(long long z) { return (z <= 1) ? 1 : z * fact(z - 1); } void fast() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } int t, q, n, m, c, d, x, y, z, a, b, cnt, arr[N], j; string second, ss; vector<string> v; int main() { fast(); cin >> n >> second; for (int i = 0; i < n; ++i) if (second[i] == '1') ++x; else ++y; if (x != y) cout << "1\n" << second << endl; else if (x - 1 != y || x != y - 1) { cout << "2\n" << second[0] << " "; cout << second.substr(1, n - 1); } else if (second[0] == '1' && x - 1 != y) { cout << "2\n1" << " "; cout << second.substr(1, n - 1); } else if (second[0] == '0' && x != y - 1) { cout << "2\n0" << " "; cout << second.substr(1, n - 1); } else { if ((second[0] == second[1]) && (x - 2 != y || x != y - 2)) { cout << "2\n" << second[0] << second[1] << " "; cout << second.substr(2, n - 1) << endl; } } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; string s; cin >> n >> s; if (n == 1) cout << 1 << endl << s << endl; else { long long z = 0, o = 0; for (long long i = 0; i < n; i++) { if (s[i] == '0') z++; else o++; } if (z != o) cout << 1 << endl << s << endl; else { cout << 2 << endl; for (long long i = 0; i < n - 1; i++) cout << s[i]; cout << " "; cout << s[n - 1]; cout << endl; } } return 0; ; }
#include <bits/stdc++.h> using namespace std; int main() { int x = 0, y = 0; int n; char a[205] = {'\0'}; scanf("%d", &n); scanf("%s", a + 1); for (int i = 1; i <= n; i++) { if (a[i] == '0') x++; else y++; } if (x == y) { printf("2\n"); printf("%c ", a[1]); for (int i = 2; i <= n; i++) printf("%c", a[i]); printf("\n"); } else { printf("1\n"); for (int i = 1; i <= n; i++) printf("%c", a[i]); printf("\n"); } }
#include <bits/stdc++.h> using namespace std; template <typename... Args> void logger(string vars, Args &&...values) { cout << vars << " = "; string delim = ""; (..., (cout << delim << values, delim = ", ")); } vector<int> isPrime(20, 1); void seive(int range) { isPrime[0] = isPrime[1] = 0; for (int i = 2; i * i <= range; i++) if (isPrime[i]) for (int j = i * i; j <= range; j += i) isPrime[j] = i; } long long mod_expo(long long n, long long exp, long long p = 1e9 + 7) { long long res = 1; while (exp > 0) { if (exp & 1) { res = ((res % p) * (n % p)) % p; exp--; }; n = ((n % p) * (n % p)) % p; exp >>= 1; } return res; } int checkPrime(int n) { if (n == 1 or n == 0) return 0; for (int i = 2; i * i <= n; i++) { if (n % i == 0) { return 0; } } return 1; } void solve() { int n; cin >> n; string second; cin >> second; map<char, int> m; for (char el : second) m[el]++; if (m['1'] == m['0']) { cout << (2) << '\n'; cout << second.substr(0, n - 1) << " " << second[n - 1] << '\n'; } else { cout << (1) << '\n'; cout << (second) << '\n'; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int ts = 1; while (ts--) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int mod = 1e9 + 7; const double eps = 1e-8; const int N = 2e5 + 5; int dir[4][2] = {0, 1, 0, -1, 1, 0, -1, 0}; int mon[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { int n; scanf("%d", &n); string str; cin >> str; int len = str.length(); if (len == 1) { puts("1"); cout << str << endl; } else { int one = 0, zero = 0; for (int i = (0); i < (len); i++) { if (str[i] - '0' == 0) zero++; else one++; } if (zero != one) { puts("1"); cout << str << endl; } else { puts("2"); cout << str[0] << " "; for (int i = (1); i < (len); i++) cout << str[i]; puts(""); } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int p; int zero = 0; int one = 0; if (n % 2 == 0) { for (int i = 0; i < n; i++) { if (s[i] == '1') { one++; } else { zero++; } } if (zero == one) { cout << 2 << endl; cout << s[0] << " "; for (int j = 1; j < n; j++) { cout << s[j]; } } if (zero != one) { cout << 1 << endl; for (int j = 0; j < n; j++) { cout << s[j]; } } } if (n % 2 != 0) { cout << 1 << endl; cout << s << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int n; cin >> n >> s; int sum0 = 0, sum1 = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') sum0++; else sum1++; } if (sum0 != sum1) cout << "1" << "\n" << s; else { cout << "2" << endl; cout << s[0] << " "; for (int i = 1; i < n; i++) { cout << s[i]; } } }
#include <bits/stdc++.h> using namespace std; int main() { string s; int n; cin >> n >> s; int l = 0, m = 0, i; vector<int> a(n); for (i = 0; i < n; i++) { if (s[i] == '1') l++; else m++; a[i] = l; } if (l != m) { cout << "1" << endl; cout << s; } else { cout << "2" << endl; cout << s[0] << " "; for (i = 1; i < n; i++) cout << s[i]; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int i, j, n, m, k, l; string str; cin >> n; cin >> str; j = 0, k = 0; for (i = 0; i < n; i++) { if (str[i] == '0') j++; else k++; } for (i = 0; i < n; i++) { if (j != k) break; if (str[i] == '0') j--; else k--; } if (i == 0) { cout << "1\n"; cout << str << "\n"; } else { cout << "2\n"; for (j = 0; j < i; j++) cout << str[j]; cout << " "; while (i < n) { cout << str[i]; i++; } cout << "\n"; } }
#include <bits/stdc++.h> using namespace std; string s; int main() { int n, o = 0, z = 0, i; scanf("%d", &n); cin >> s; for (i = 0; i < n; i++) s[i] == '0' ? z++ : o++; if (z != o) cout << 1 << endl << s; else { cout << 2 << endl << s[0] << ' '; for (i = 1; i < n; i++) cout << s[i]; } return 0; }
#include <bits/stdc++.h> #pragma GCC optimize("-O3") const long long N = 100005; using namespace std; void pairsort(long long a[], long long b[], long long n) { pair<long long, long long> pairt[n]; for (long long i = 0; i < n; i++) { pairt[i].first = a[i]; pairt[i].second = b[i]; } sort(pairt, pairt + n); for (long long i = 0; i < n; i++) { a[i] = pairt[i].first; b[i] = pairt[i].second; } } bool isPrime(long long n) { if (n < 2) return 0; for (long long i = 2; i <= sqrt(n); i++) { if (n % i == 0) return 0; } return 1; } long long factorial(long long n) { long long i = 1; for (long long j = 1; j <= n; j++) i *= j; return i; } long long nCr(long long n, long long r) { return factorial(n) / (factorial(r) * factorial(n - r)); } long double modd(long double x) { if (x >= 0) return x; return -1 * x; } long long dp(long long y) { long long s = 0; while (y != 0) { long long r = y % 10; s += r; y /= 10; } if (s % 10 == 0) return 1; return 0; } long long sd(long long n) { long long s = 0; while (n != 0) { s += n % 10; n /= 10; } return s; } long long mod = 1e9 + 7; long long modexpo(long long x, unsigned long long y) { long long res = 1; x = x % mod; while (y > 0) { if (y & 1) res = (res * x) % mod; y = y >> 1; x = (x * x) % mod; } return res; } long long ps(long long n) { long double x = (long double)n; if (ceil(sqrt(x)) == floor(sqrt(x))) return 1; return 0; } vector<long long> adj[N]; vector<long long> cost; long long src, des, w; vector<long long> vis; vector<long long> dist, res, parent; long long n, k; long long p = 1; void dfs(long long x) { vis[x] = 1; for (long long i = 0; i < adj[x].size(); i++) { if (!vis[adj[x][i]]) { dfs(adj[x][i]); } } } void bfs() { long long s = 1; queue<long long> q; q.push(s); parent[s] = 1; vis[s] = 1; while (!q.empty()) { s = q.front(); q.pop(); for (long long i = 0; i < adj[s].size(); i++) { if (!vis[adj[s][i]]) { q.push(adj[s][i]); vis[adj[s][i]] = 1; parent[adj[s][i]] = s; } } } } vector<long long> v; map<long long, long long> m; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; string s; cin >> n >> s; long long c1 = 0, c0 = 0; for (long long i = 0; i < n; i++) { if (s[i] == '1') c1++; else c0++; } if (c1 != c0) { cout << 1 << "\n"; cout << s; } else { long long a, d; a = 0, d = 0; for (long long i = 0; i < n; i++) { if (s[i] == '1') a++; else d++; if (a != d) { cout << 2 << "\n"; for (long long j = 0; j <= i; j++) cout << s[j]; cout << " "; for (long long j = i + 1; j < n; j++) cout << s[j]; return 0; } } } }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string s; cin >> s; if (N % 2 != 0) { cout << 1 << "\n" << s << "\n"; } else { int one = count(s.begin(), s.end(), '1'); int zero = count(s.begin(), s.end(), '0'); if (one == zero) { cout << 2 << "\n"; cout << s.substr(0, s.size() - 1) << " " << s.substr(s.size() - 1, s.size()) << "\n"; } else { cout << 1 << "\n" << s << "\n"; } } return 0; }
#include <bits/stdc++.h> using namespace std; int s[1000005], d[1000005]; char a[1000005]; int main() { int n, m, i, j, k; char b; scanf("%d", &n); s[0] = 0, s[1] = 0; scanf("%s", a); for (i = 0; i < n; i++) s[a[i] - '0']++; if (s[1] == s[0]) { printf("2\n"); printf("%c ", a[0]); printf("%s", a + 1); } else printf("1\n%s", a); }
#include <bits/stdc++.h> using namespace std; const int N = 105; int n; int zero[N], one[N]; string str; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> str; zero[0] = 0, one[0] = 0; str = " " + str; for (int i = 1; i < str.size(); i++) { if (str[i] == '1') { zero[i] = zero[i - 1]; one[i] = one[i - 1] + 1; } else if (str[i] == '0') { zero[i] = zero[i - 1] + 1; one[i] = one[i - 1]; } } for (int i = 0; i <= n; i++) { if (zero[n] != one[n]) { cout << 1 << endl; for (int i = 1; i < str.size(); i++) { cout << str[i]; } break; } else if (zero[i] != one[i] && zero[n] - zero[i] != one[n] - one[i]) { cout << 2 << endl; for (int j = 1; j <= i; j++) { cout << str[j]; } cout << " "; for (int j = i + 1; j < str.size(); j++) { cout << str[j]; } break; } } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int countpos(string s, int x) { int fh0 = 0, fh1 = 0, sh0 = 0, sh1 = 0; for (int i = 0; i < x; i++) { if (s[i] == '1') { fh1++; } else { fh0++; } } for (int i = x; i < s.length(); i++) { if (s[i] == '1') { sh1++; } else { sh0++; } } if (sh1 == fh1 && sh0 == fh0) { return x - 1; } else { return x; } } int main() { int n; string s; int countz = 0, counto = 0, count = 0; cin >> n >> s; for (int i = 0; i < n; i++) { if (s[i] == '1') { counto++; } else { countz++; } } if (counto != countz) { cout << 1 << endl << s; } else { int x = countpos(s, s.length() / 2); cout << 2 << endl; for (int i = 0; i < x; i++) { cout << s[i]; } cout << " "; for (int i = x; i < s.length(); i++) { cout << s[i]; } } }
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k = 0, l, m, n, c = 0; string s; vector<int> v; map<int, int> mp; scanf("%d", &n); cin >> s; for (i = 0; i < n; i++) { if (s[i] == '0') c++; else k++; } if (c != k) { printf("1\n"); cout << s << endl; } else { for (j = 0; j < n - 1; j++) { c = 0; k = 0; for (i = 0; i <= j; i++) { if (s[i] == '0') c++; else k++; } if (c != k) { c = 0; k = 0; for (i = j + 1; i < n; i++) { if (s[i] == '0') c++; else k++; } if (c != k) { printf("2\n"); for (i = 0; i <= j; i++) { cout << s[i]; } cout << " "; for (i = j + 1; i < n; i++) { cout << s[i]; } cout << endl; return 0; } } } } }
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); string str; cin >> str; int i0 = 0, i1 = 0; for (int i = 0; i < str.size(); ++i) { if (str[i] == '0') { ++i0; } else { ++i1; } } if (i0 == i1) { printf("2\n"); cout << str[0] << " " << str.substr(1, str.size() - 1); } else { printf("1\n"); cout << str; } }
#include <bits/stdc++.h> using namespace std; const int maxn = 2e4 + 6; const long long mod = 998244353; int n; char str[maxn]; int l[maxn], r[maxn]; int main() { scanf("%d", &n); scanf("%s", str + 1); if (n == 1) { printf("1\n"); printf("%s", str + 1); return 0; } int s = 0, t = 0; for (int i = 1; i <= n; ++i) { if (str[i] == '1') s++; else t++; } if (s == t) { printf("2\n"); printf("%c ", str[1]); printf("%s", str + 2); } else { printf("1\n"); printf("%s", str + 1); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int T, n, m, k, i, count = 0, j; vector<long long int> b; string a; T = 1; while (T--) { cin >> n; cin >> a; for (j = 0; j < n; j++) { count += (a[j] - '0'); } if (count * 2 == n) { cout << "2\n" << a[0] << " "; for (i = 1; i < n; i++) { cout << a[i]; } cout << "\n"; } else { cout << "1\n" << a << "\n"; } } return 0; }
#include <bits/stdc++.h> using namespace std; int su0, su1; int main() { int i, n; string s; cin >> n; cin >> s; for (i = 0; i < s.length(); i++) { if (s[i] - '0' == 0) su0++; else su1++; } if (su0 != su1) { cout << 1 << endl; cout << s; return 0; } cout << 2 << endl; for (i = 0; i < s.length() - 1; i++) { cout << s[i]; } cout << ' ' << s[n - 1]; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n; cin.get(); getline(cin, s); int z = 0, e = 0; for (size_t i = 0; i < n; i++) { if (s[i] == '0') z++; else e++; } if (z != e) { cout << 1 << endl; cout << s; } else { cout << 2 << endl; cout << s.substr(0, n - 1) << " " << s[n - 1]; } return 0; }
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; int main() { ios::sync_with_stdio(false); int n; cin >> n; string s; cin >> s; int u = 0; int z = 0; for (int i = 0; i < n; i++) { if (s[i] == '1') u++; else z++; } if (u != z) cout << 1 << endl << s << endl; else { cout << 2 << endl; char ok = s.back(); s.pop_back(); cout << s << " " << ok << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; string s; cin >> s; long long int c0 = 0, c1 = 0; for (int i = 0; i < s.length(); i++) { if (s[i] == '0') c0++; else c1++; } if (c0 != c1) { cout << 1 << endl; cout << s << endl; } else { cout << 2 << endl; cout << s[0] << " " << s.substr(1, s.length()) << endl; } }
#include <bits/stdc++.h> using namespace std; template <class FR> inline FR max(FR &a, const FR &b) { return (a > b) ? a : b; } template <class FR> inline FR min(FR &a, const FR &b) { return (a > b) ? b : a; } template <class FR> inline FR eqMax(FR &a, FR b) { return (a > b) ? a : a = b; } template <class FR> inline FR eqMin(FR a, FR b) { return (a > b) ? a = b : a; } int main() { ios_base::sync_with_stdio(false); int n; cin >> n; string s; cin >> s; int cnt0 = 0, cnt1 = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') { cnt0++; } else { cnt1++; }; } if (cnt1 != cnt0) { cout << 1 << endl; cout << s << endl; return 0; } cout << 2 << endl; cout << s[0] << ' '; reverse(s.begin(), s.end()); s.pop_back(); reverse(s.begin(), s.end()); cout << s << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int cnt1 = 0, cnt0 = 0; if (n % 2 != 0) { cout << 1 << endl; cout << s << endl; } else { for (int i = 0; i < n; i++) { if (s[i] == '0') { cnt0++; } else { cnt1++; } } if (cnt0 != cnt1) { cout << 1 << endl; cout << s; } else { cout << 2 << endl; for (int i = 0; i < n - 1; i++) { cout << s[i]; } cout << " " << s[n - 1]; } } }
#include <bits/stdc++.h> int main() { int t; std::cin >> t; std::string ss; std::cin >> ss; long long _1, _0; _1 = _0 = 0; for (int i = 1; i <= t; ++i) { ss[i - 1] == '0' ? _0++ : _1++; } if (_0 != _1) { std::cout << 1 << std::endl; std::cout << ss << std::endl; return 0; } else { std::cout << 2 << std::endl; std::cout << ss[0] << " "; for (int i = 1; i < t; ++i) std::cout << ss[i]; std::cout << std::endl; return 0; } }
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr); long long n; cin >> n; string s; cin >> s; long long a = 0, b = 0; for (auto& i : s) { if (i == '1') ++a; else ++b; } if (a == b) { cout << "2\n"; cout << s[0] << ' '; for (long long i = 1; i < n; ++i) cout << s[i]; } else { cout << "1\n"; cout << s; } cout << '\n'; }
#include <bits/stdc++.h> using namespace std; int main() { int n, one = 0, zero = 0; string s; cin >> n; cin >> s; for (char c : s) { if (c == '1') ++one; else ++zero; } if (one == zero) { cout << 2 << '\n'; for (int i = 0; i <= n - 2; i++) cout << s[i]; cout << " "; cout << s[n - 1]; } else { cout << 1 << '\n' << s; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string a; while (cin >> n) { cin >> a; int s1 = 0, s0 = 0; for (int i = 0; i < n; i++) { if (a[i] == '1') s1++; else s0++; } if (s0 != s1) cout << 1 << endl << a << endl; else { cout << 2 << endl; cout << a[0] << " "; for (int i = 1; i < n; i++) { cout << a[i]; } cout << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, one = 0, zero = 0; string str; cin >> n >> str; if (n == 1) cout << 1 << '\n' << str[0]; else { for (int i = 0; i < n; i++) { if (str[i] == '1') one++; else zero++; } if (one != zero) cout << 1 << '\n' << str; else { cout << 2 << '\n' << str[0] << ' '; for (int i = 1; i < n; i++) cout << str[i]; cout << '\n'; } } return 0; }
#include <bits/stdc++.h> using namespace std; long long n, x, y; string s; void solve() { cin >> n >> s; for (auto i : s) { if (i == '0') x++; else y++; } if (x != y) { cout << 1 << "\n" << s << "\n"; return; }; cout << 2 << "\n"; cout << s[0] << " "; cout << s.substr(1, n - 1) << " "; } void prep() {} int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t = 1; prep(); cout << fixed << setprecision(12); while (t--) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 2e6 + 17; const int darr = 1e3 + 17; const int MAXN = 4 * maxn; const long long mod = 1e9 + 7; int n; string s; void timeBoost() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } bool ok(string s) { int ct1 = 0, ct2 = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '1') { ct1++; } else { ct2++; } } if (ct1 != ct2) { return 1; } else { return 0; } } vector<string> v; int main() { timeBoost(); cin >> n; cin >> s; if (ok(s)) { cout << 1 << '\n'; cout << s; return 0; } string sub1 = s.substr(0, n / 2); string sub2 = s.substr(n / 2, n - (n / 2)); if (ok(sub1) == 1 && ok(sub2) == 1) { cout << 2 << '\n' << sub1 << ' ' << sub2; } else { if (ok(sub1) == 0) { char sub1_ch = sub1[sub1.size() - 1]; sub1.erase(sub1.size() - 1); reverse((sub2).begin(), (sub2).end()); sub2 += sub1_ch; reverse((sub2).begin(), (sub2).end()); cout << 2 << '\n'; cout << sub1 << ' ' << sub2; } else { char sub2_ch = sub2[sub2.size() - 1]; sub2.erase(sub2.size() - 1); sub1 += sub2_ch; cout << 2 << '\n'; cout << sub1 << ' ' << sub2; } } return 0; }
#include <bits/stdc++.h> using namespace std; int o[105], z[105]; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n, a, b; a = 0; b = 0; string str; cin >> n >> str; for (int i = 0; i < str.size(); i++) { if (str[i] == '1') a++; if (str[i] == '0') b++; o[i] = a; z[i] = b; } int ans = 0; if (a != b) { cout << "1\n" << str << endl; } else { cout << "2\n"; for (int i = 0; i < str.size() - 1; i++) cout << str[i]; cout << " " << str[str.size() - 1] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char arr[1000]; char arr2[1000]; long long n, i, j, l, cnt0 = 0, cnt1 = 0; cin >> l; cin >> arr; for (i = 0; i < l; i++) { if (arr[i] == '1') cnt1++; else cnt0++; } if (cnt0 != cnt1) cout << 1 << endl << arr << endl; else { j = 0; cnt0 = 0; cnt1 = 0; for (i = 1; i < l; i++) { arr2[j++] = arr[i]; if (arr[i] == '1') cnt1++; else cnt0++; } if (cnt0 != cnt1) { cout << 2 << endl << arr[0] << " "; for (i = 0; i < l - 1; i++) cout << arr2[i]; cout << endl; } else { j = 0; cnt0 = 0; cnt1 = 0; for (i = 2; i < l; i++) { arr2[j++] = arr[i]; if (arr[i] == '1') cnt1++; else cnt0++; } if (cnt0 != cnt1) { cout << 2 << endl << arr[0] << arr[1] << " "; for (i = 0; i < l - 2; i++) cout << arr2[i]; cout << endl; } } } }
#include <bits/stdc++.h> using namespace std; int main() { int one = 0, zero = 0, n; string s; cin >> n >> s; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') zero++; else one++; } if (zero != one) { cout << 1 << endl << s; } else { cout << 2 << endl << s[0] << " "; for (int i = 1; i < s.size(); i++) cout << s[i]; } return 0; }
#include <bits/stdc++.h> using namespace std; namespace Sameh { void ios_base() { ios_base::sync_with_stdio(0); cin.tie(0); } void endl() { cout << '\n'; } void Erase_To(vector<long long>& R, long long To) { for (long long i = 0; i <= To; i++) { R.erase(R.begin()); } return; } void Erase_From(vector<long long>& R, long long To) { for (long long i = 0; i < To; i++) { R.erase(R.end() - 1); } return; } long long Sum_of_digits(long long x) { long long Answer = 0; while (x != 0) { Answer += x % 10; x -= x % 10; x /= 10; } return Answer; } template <typename E1, typename N2> long long binary_search(E1 S, N2 F) { long long First = 0; long long Last = (S.size()) - 1; long long Mid = (First + Last) / 2; while (!S.empty()) { First = 0; Last = (S.size()) - 1; Mid = (First + Last) / 2; if (S[Mid] == F) { return Mid; } else if (S[Mid] > F) { long long Erase = (Last - Mid); Erase_From(S, Erase); } else if (S[Mid] < F) { long long Erase = Mid; Erase_To(S, Erase); } } return -1; } } // namespace Sameh int32_t main() { Sameh::ios_base(); long long n; cin >> n; long long i, d = 0; string s; cin >> s; for (i = 0; i < n; i++) d += s[i] - '0' ? 1 : -1; cout << (d ? "1\n" + s : "2\n" + s.substr(0, 1) + " " + s.substr(1)); return 0; }
#include <bits/stdc++.h> using namespace std; char c[101]; int main() { int n, nr0 = 0, nr1 = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> c[i]; if (c[i] == '0') nr0++; else nr1++; } if (nr1 == nr0) { cout << "2\n"; cout << c[0] << " "; for (int i = 1; i < n; i++) { cout << c[i]; } } else { cout << "1\n"; for (int i = 0; i < n; i++) { cout << c[i]; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int cnt_zero = 0; int cnt_one = 0; for (int i = 0; i < n; i++) { if (s[i] == '0') { cnt_zero++; } else { cnt_one++; } } if (cnt_zero != cnt_one) { cout << "1" << endl << s; } else { cout << "2" << endl << s[0] << " "; for (int i = 1; i < n; i++) { cout << s[i]; } } return 0; }
#include <bits/stdc++.h> using namespace std; char arr[1000010]; int cnt[10]; int main() { int n; cin >> n; int x; for (x = 1; x <= n; x++) { cin >> arr[x]; cnt[(int)(arr[x] - '0')]++; } if (cnt[0] == cnt[1]) { cout << "2" << endl; for (x = 1; x < n; x++) { cout << arr[x]; } cout << " "; cout << arr[n]; } else { cout << "1" << endl; for (x = 1; x <= n; x++) { cout << arr[x]; } } }
#include <bits/stdc++.h> using namespace std; int n, o; string s; int main() { cin >> n >> s; if (n % 2 == 1) { cout << 1 << endl << s; return 0; } for (int i = 0; i < n; i++) { if (s[i] == '0') o++; } if (o != n - o) cout << 1 << endl << s; else cout << 2 << endl << s[0] << " " << s.substr(1, n - 1); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int n, c1 = 0; cin >> n >> s; for (int i = 0; i < n; ++i) { if (s[i] == '1') ++c1; } if (c1 == (n - c1)) { cout << "2\n"; for (int i = 0; i < n - 1; ++i) cout << s[i]; cout << " " << s[n - 1]; } else { cout << "1\n"; cout << s; } return 0; }
#include <bits/stdc++.h> using namespace std; struct Edge { int from, to, dist; Edge(int u, int v, int d) : from(u), to(v), dist(d) {} }; int n; char s[200]; int cnt = 0; int main() { cin >> n >> s; int len = strlen(s); for (int i = 0; i < len; i++) { if (s[i] == '0') cnt++; } if (cnt * 2 == n) { cout << 2 << endl; cout << s[0] << " "; for (int i = 1; i < len; i++) cout << s[i]; cout << endl; } else { cout << 1 << endl; cout << s << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; string s; cin >> s; if (n == 1) { cout << 1 << endl << s; return 0; } int x = 0, y = 0; for (int i = 0; i < n; i++) if (s[i] == '0') x++; else y++; if (x == y) { cout << 2 << endl; cout << s[0] << ' '; for (int i = 1; i < n; i++) cout << s[i]; return 0; } else { cout << 1 << endl; cout << s; return 0; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; char s[10005]; scanf("%d", &n); scanf("%s", s); int one = 0, zero = 0; int len = strlen(s); for (int i = 0; i < n; i++) { if (s[i] == '0') zero++; else one++; } if (zero != one) { printf("1\n%s\n", s); } else { printf("2\n"); for (int i = 0; i < len - 1; i++) { printf("%c", s[i]); } printf(" %c", s[len - 1]); } return 0; }
#include <bits/stdc++.h> char s[110]; int main() { int n, l = 0, r = 0; scanf("%d%s", &n, s); for (int i = 0; i < n; i++) { if (s[i] == '1') l++; else r++; } if (l == r) { printf("2\n%c ", s[0]); for (int i = 1; i < n; i++) printf("%c", s[i]); } else printf("1\n%s", s); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, c = 0, cc = 0, o = 0; string s; cin >> n >> s; for (long long i = 0; i < n; i++) if (s[i] == '1') c++; else o++; if (c == o) { cout << 2 << endl; c = 0; o = 0; for (long long i = 0; i < n; i++) { cout << s[i]; if (s[i] == '1') c++; else o++; if (c != o && cc == 0) { cc = 1; cout << ' '; } } } else cout << 1 << endl << s << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); string s; cin >> s; int cnt0 = 0, cnt1 = 0; for (int i = 0; i < s.length(); ++i) { if (s[i] == '0') cnt0++; else cnt1++; } if (cnt1 != cnt0) { printf("%d\n", 1); cout << s; } else { printf("%d\n", 2); printf("%c ", s[0]); for (int i = 1; i < s.length(); ++i) printf("%c", s[i]); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; while (cin >> n) { int ans = 0; cin >> s; for (int i = 0; i < n; i++) { if (s[i] == '0') ans++; else ans--; } if (ans) { cout << "1" << endl; cout << s << endl; } else { cout << "2" << endl; cout << s[0] << " "; for (int i = 1; i < n; i++) { cout << s[i]; } cout << endl; } } return 0; }
#include <bits/stdc++.h> int main() { char ch[1000]; int n, num1 = 0, num0 = 0, x, num_1 = 0, num_0 = 0, len, i; scanf("%d%s", &n, &ch); len = strlen(ch); for (i = 0; i < n; i++) { if (ch[i] == '0') num0++; if (ch[i] == '1') num1++; } if (num0 != num1) { printf("1\n"); printf("%s", ch); } else { printf("2\n"); if (num0 > num1) { x = num0 - num1; for (i = 0; 1; i++) { if (ch[i] == '0') num_0++; if (ch[i] == '1') num_1++; printf("%c", ch[i]); if (num_0 - num_1 != x) break; } printf(" "); for (i++; i < len; i++) printf("%c", ch[i]); } else x = num1 - num0; for (i = 0; 1; i++) { if (ch[i] == '0') num_0++; if (ch[i] == '1') num_1++; printf("%c", ch[i]); if (num_1 - num_0 != x) break; } printf(" "); for (i++; i < len; i++) printf("%c", ch[i]); } }
#include <bits/stdc++.h> using namespace std; signed main() { long long n; cin >> n; string s; cin >> s; if (n % 2) cout << "1\n" << s; else { long long c = 0; for (long long i = 0; i < n; ++i) { if (s[i] == '1') c++; } if (c != n / 2) cout << "1\n" << s; else cout << "2\n" << s[0] << " " << s.substr(1, n - 1); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int x = 0, y = 0; char s[n]; for (int i = 0; i < n; i++) { cin >> s[i]; if (s[i] == '0') y++; else x++; } if (x == y) { cout << "2" << endl << s[0] << " "; for (int i = 1; i < n; i++) cout << s[i]; } else { cout << "1" << endl; for (int i = 0; i < n; i++) cout << s[i]; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n; string s; cin >> n >> s; int one = 0, zero = 0; for (int i = 0; i < n; i++) { if (s[i] == '1') one++; else zero++; } if (one != zero) cout << 1 << '\n' << s << endl; else { cout << 2 << endl; cout << s[0] << " "; s.erase(0, 1); cout << s << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, c0 = 0, c1 = 0; cin >> n; char A[n]; cin >> A; for (i = 0; i < n; i++) if (A[i] == '0') c0++; else c1++; if (c0 != c1) cout << 1 << endl << A << endl; else { cout << 2 << endl << A[0] << " "; for (i = 1; i < n; i++) cout << A[i]; cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; if (n % 2) cout << 1 << endl << s << endl; else { int ones = 0, zeros = 0; for (int i = 0; i < n; i++) { if (s[i] == '0') zeros++; else ones++; } if (ones == zeros) { cout << 2 << endl << s[0] << " " << s.substr(1) << endl; } else cout << 1 << endl << s << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int32_t main() { long long n; string s; cin >> n >> s; long long cnt0 = 0, cnt1 = 0; for (long long i = 0; i < n; i++) { if (s[i] == '0') cnt0++; else cnt1++; } if (cnt1 == cnt0) { cout << 2 << endl; cout << s[0] << ' '; for (long long i = 1; i < n; i++) cout << s[i]; } else { cout << 1 << endl << s; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n; int count = 0; cin >> s; for (int i = 0; i < n; i++) { if (s[i] == '0') count++; else count--; } if (count != 0) { cout << 1 << endl; cout << s; } else { cout << 2 << endl; for (int i = 0; i < n - 1; i++) { cout << s[i]; } cout << " " << s[n - 1] << endl; } }
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5 + 5; set<int> s1; int arr[MAXN]; map<int, int> m1; int righti[MAXN]; int ans; int z1, o1, z2, o2; int main() { int n; cin >> n; string s; cin >> s; string a = ""; for (int i = 0; i < n; i++) { if (s[i] == '0') { z1++; } else { o1++; } } if (z1 != o1) { cout << 1 << endl; cout << s << endl; return 0; } z1 = 0; o1 = 0; for (int i = 0; i < n; i++) { a += s[i]; if (s[i] == '0') { z1++; } else { o1++; } string b = ""; for (int j = i + 1; j < n; j++) { if (s[j] == '0') { z2++; } else { o2++; } b += s[j]; } if (z1 != o1 && z2 != o2) { cout << 2 << endl; cout << a << " " << b << endl; return 0; } } cout << 1 << endl; cout << s << endl; }
#include <bits/stdc++.h> int zero, one; char a[11111]; int n; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { std::cin >> a[i]; if (a[i] == '0') { zero++; } else { one++; } } if (zero == one) { printf("2\n"); printf("%c ", a[1]); for (int i = 2; i <= n; i++) printf("%c", a[i]); } else { printf("1\n"); for (int i = 1; i <= n; i++) { printf("%c", a[i]); } } return 0; }
#include <bits/stdc++.h> using namespace std; long long int MOD = 1000000007; long int idx[100001]; long long int power(long long int x, long long int y, long long int z) { long long int res = 1; x %= z; while (y > 0) { if (y & 1) res = (res * x) % z; x = (x * x) % z; y /= 2; } return res; } long long int power1(long long int x, long long int y) { long long int res = 1; while (y > 0) { if (y & 1) res = (res * x); x = (x * x); y /= 2; } return res; } long int root(long int x) { while (idx[x] != x) x = idx[x]; return x; } void union1(long int x, long int y) { idx[root(x)] = root(y); } int main() { long int n; cin >> n; string a; cin >> a; long int aa = 0, bb = 0; for (long int i = 0; i < n; i++) { if (a[i] == '0') aa++; else bb++; } if (aa == bb) { cout << "2" << endl; for (long int i = 0; i < n - 1; i++) cout << a[i]; cout << " " << a[n - 1]; } else { cout << "1" << endl; for (long int i = 0; i < n; i++) cout << a[i]; } }
#include <bits/stdc++.h> using namespace std; int main() { int n, i, o = 0, z = 0; cin >> n; string s; cin >> s; for (i = 0; i < n; i++) { if (s[i] == '1') o++; else z++; } if (z != o) { cout << 1 << endl << s; } else { cout << 2 << endl; for (i = 0; i < n - 1; i++) cout << s[i]; cout << " " << s[n - 1]; } }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, zr = 0, one = 0; cin >> n; string st; cin >> st; for (long long int i = 0; i < n; i++) { if (st[i] == '0') zr += 1; else one++; } if (one != zr) { cout << 1 << endl; cout << st << endl; return 0; } else { cout << 2 << endl; cout << st[0] << " "; for (long long int i = 1; i < n; i++) { cout << st[i]; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n; cin >> s; int one, zero; one = zero = 0; for (int i = 0; i < n; i++) { if (s[i] == '1') one++; else if (s[i] == '0') zero++; } if (one != zero) { cout << 1 << '\n' << s << '\n'; } else { cout << 2 << '\n' << s[0] << " " << s.substr(1, n) << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int i, count = 0; for (i = 0; i < n; i++) { if (s[i] == '1') count++; } if (count == n - count) { cout << 2 << "\n"; for (i = 0; i < n - 1; i++) { cout << s[i]; } cout << " "; cout << s[n - 1] << "\n"; } else { cout << 1 << "\n"; cout << s << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; bool isb(string s) { int z = 0; int o = 0; for (int i = 0; i < s.length(); i++) { if (s[i] == '0') { z++; } else { o++; } } if (z == o) { return true; } else { return false; } } int main() { int n; cin >> n; string s; cin >> s; if (isb(s)) { cout << 2 << endl; string a1 = s.substr(0, n - 1); cout << a1 << " " << s[n - 1] << endl; } else { cout << 1 << endl; cout << s << endl; } }
#include <bits/stdc++.h> using namespace std; int n; string s; int main() { cin >> n >> s; int cnt_o_all = 0, cnt_z_all = 0; for (int i = 0; i < n; i++) { if (s[i] == '1') cnt_o_all++; else cnt_z_all++; } if (cnt_o_all != cnt_z_all) { cout << 1 << "\n"; cout << s; return 0; } int choosed_z = 0, choosed_o = 0; for (int i = 0; i < n; i++) { if (((cnt_o_all - choosed_o) != (cnt_z_all - choosed_z)) && (choosed_o != choosed_z || (choosed_o == 0 && choosed_z == 0))) { if (n == 1) { cout << 1 << "\n"; cout << s; return 0; } cout << 2 << "\n"; for (int j = 0; j < i; j++) cout << s[j]; cout << " "; for (int j = i; j < n; j++) cout << s[j]; return 0; } if (s[i] == '1') choosed_o++; else choosed_z++; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; int z = 0, o = 0; for (char c : s) { z += c == '0', o += c == '1'; } if (z != o) { cout << 1 << endl; cout << s << endl; } else { cout << 2 << endl; cout << s[0] << " " << s.substr(1) << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string str; cin >> str; if (n % 2 == 1) cout << 1 << endl << str; if (n % 2 == 0) { int one = 0, zero = 0; for (int i = 0; str[i] != '\0'; i++) { if (str[i] == '1') one++; else zero++; } if (one != zero) cout << 1 << endl << str; else cout << 2 << endl << str[0] << " " << str.substr(1, n); } return 0; }
#include <bits/stdc++.h> using namespace std; int mod = 1000000007; int compare(const void* p, const void* q) { int a = *(const int*)p; int b = *(const int*)q; return a - b; } int main() { std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; int count0 = 0, count1 = 0; int i; string x; cin >> x; for (i = 0; i < n; i++) { if (x[i] == '0') count0++; else count1++; } if (n % 2 || count1 != count0) { cout << "1\n"; cout << x << endl; } else { cout << "2\n"; if (n / 2 % 2) cout << x.substr(0, n / 2) << " " << x.substr(n / 2, n - 1) << endl; else cout << x.substr(0, n / 2 - 1) << " " << x.substr(n / 2 - 1, n - 1) << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> ostream &operator<<(ostream &os, const vector<T> &p) { os << "["; for (auto &it : p) os << it << " "; return os << "]"; } template <class S, class T> ostream &operator<<(ostream &os, const pair<S, T> &p) { return os << "(" << p.first << "," << p.second << ")"; } template <class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; } const long long N = 2e5 + 10; void solve() { long long n; cin >> n; string s; cin >> s; if (count(s.begin(), s.end(), '0') == (n / 2) && n % 2 == 0) { cout << 2 << endl << s[0] << ' ' << s.substr(1) << endl; } else cout << "1\n" << s << endl; } signed main() { ios_base::sync_with_stdio(false), cin.tie(nullptr); long long q = 1; while (q--) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { if (a.first == b.first) return (a.second < b.second); return (a.first < b.first); } vector<long long int> prime(1000005, 1); void p() { long long int i, j; for (i = 2; i <= 1000000; i++) { if (prime[i] == 1) { for (j = 2 * i; j <= 1000000; j += i) prime[j] = 0; } } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, i; cin >> n; string s; cin >> s; long long int t1 = 0, t0 = 0; for (i = 0; i < n; i++) { if (s[i] == '0') t0++; else t1++; } if (n % 2 == 1 || t0 == n || t1 == n || t0 != t1) { cout << 1 << "\n"; cout << s << "\n"; } else { cout << 2 << "\n"; for (i = 0; i < (n - 1); i++) cout << s[i]; cout << " "; cout << s[n - 1] << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; long long add(long long a, long long b, long long mod) { return (a % mod + b % mod) % mod; } long long sub(long long a, long long b, long long mod) { return (a % mod - b % mod + mod) % mod; } long long mul(long long a, long long b, long long mod) { return (a % mod * b % mod) % mod; } long long sumodd(long long num, long long mod) { return mul(num, num, mod); } long long sumeven(long long num, long long mod) { return mul(num, num + 1, mod); } long long sumrange(long long st, long long en, long long num) { return (num * (st + en) / 2); } long long gcd(long long a, long long b) { while (b != 0) { long long a2 = a; a = b; b = a2 % b; } return a; } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } string makeitbinary(long long n) { string s; while (n) { s = s + (char)((n % 2) + '0'); n /= 2; } reverse(s.begin(), s.end()); return s; } bool bit(int num, int i) { return ((num >> i) & 1); } long long fastpowermod(long long b, long long p, long long mod) { long long ans = 1; while (p) { if (p % 2) { ans = mul(ans, b, mod); } b = mul(b, b, mod); p /= 2; } return ans; } long long fastpower(long long b, long long p) { long long ans = 1; while (p) { if (p % 2) { ans = ans * b; } b = b * b; p /= 2; } return ans; } double fastpower_double(double b, long long p) { double ans = 1; while (p) { if (p % 2) { ans = ans * b; } b = b * b; p /= 2; } return ans; } long long summation_formula(long long n) { return (n * (n + 1) / 2); } bool lower_vowel(char c) { return (c == 'i' || c == 'o' || c == 'u' || c == 'a' || c == 'e'); } string bigint_mini(string s1, string s2) { if (s1.size() > s2.size()) { return s2; } else if (s2.size() > s1.size()) { return s1; } for (int i = 0; i < s1.size(); i++) { if ((s1[i] - '0') > (s2[i] - '0')) { return s2; } else if ((s2[i] - '0') > (s1[i] - '0')) { return s1; } } return s1; } double polygon_area(int n, vector<double> X, vector<double> Y) { double area = 0.0; int j = n - 1; for (int i = 0; i < n; i++) { area += (X[j] + X[i]) * (Y[j] - Y[i]); j = i; } return abs(area / 2.0); } long long sum_of_digits(string s) { long long sum = 0; for (int i = 0; i < s.size(); i++) { sum += s[i] - '0'; } return sum; } string makeitbase(long long num, long long base) { string s; while (num) { long long mod = num % base; s += (mod + '0'); num /= base; } reverse(s.begin(), s.end()); return s; } bool intersect(long long l1, long long r1, long long l2, long long r2) { return (max(l1, l2) <= min(r1, r2)); } pair<long long, long long> find_intersection(long long l1, long long r1, long long l2, long long r2) { return {max(l1, l2), min(r1, r2)}; } long long sum_ranges(long long l, long long r) { return summation_formula(r) - summation_formula(l); } double power_2(double num) { return num * num; } const int sz = 3e5 + 1; long long M = 1e9 + 7; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n; cin >> n; string s; cin >> s; int cntz = 0; int cnto = 0; for (int i = 0; i < s.size(); i++) { cntz += (s[i] == '0'); cnto += (s[i] == '1'); } if (cnto != cntz) { cout << 1 << endl; cout << s << endl; return 0; } cout << 2 << endl; cout << s[0] << " "; for (int i = 1; i < s.size(); i++) { cout << s[i]; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; if (n % 2) { cout << 1 << '\n' << s << endl; } else { int a, b; a = b = 0; for (int i = 0; i < n; i++) { if (s[i] == '1') { ++a; } else { ++b; } } if (a == b) { cout << 2 << endl; cout << s.substr(0, n - 1) << ' ' << s[n - 1] << endl; } else { cout << 1 << '\n' << s << endl; } } }
#include <bits/stdc++.h> using namespace std; int main() { string str; getline(cin, str); getline(cin, str); int counterZero = 0; int counterOnes = 0; for (char i : str) { i == '0' ? counterZero++ : counterOnes++; } if (counterZero == counterOnes) { cout << 2 << endl << str.substr(0, 1) << ' ' << str.substr(1); } else { cout << 1 << endl << str; } return 0; }