#include <bits/stdc++.h> #define vt vector #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define F first #define S second #define pb emplace_back #define pii pair <int, int> typedef long long ll; using namespace std; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; int o = 0; for (int i = 0; i < n * 8; i++) { char c = getchar(); if (c == '1') o++; } if (o < 3 * n || o > 6 * n) { cout << "NIE\n"; return 0; } o -= 3 * n; for (int i = 0; i < n; i++) { if (o >= 3) { cout << "o"; o -= 3; } else if (o == 2) { cout << "k"; o -= 2; } else if (o == 1) { cout << "c"; o -= 1; } else cout << "a"; } cout << " \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 | #include <bits/stdc++.h> #define vt vector #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define F first #define S second #define pb emplace_back #define pii pair <int, int> typedef long long ll; using namespace std; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; int o = 0; for (int i = 0; i < n * 8; i++) { char c = getchar(); if (c == '1') o++; } if (o < 3 * n || o > 6 * n) { cout << "NIE\n"; return 0; } o -= 3 * n; for (int i = 0; i < n; i++) { if (o >= 3) { cout << "o"; o -= 3; } else if (o == 2) { cout << "k"; o -= 2; } else if (o == 1) { cout << "c"; o -= 1; } else cout << "a"; } cout << " \n"; } |