#include <bits/stdc++.h>
using namespace std;
int cnt[2];
/*
* Ruchy -
*
*
*
*/
int licz[2];
set<tuple<int, int, char>> moves;
vector<pair<int, char>> ez_moves;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
for(int j = 97; j <= 96 + 26; ++j) {
licz[0] = licz[1] = 0;
for(int x = 0; x < 8; ++x) {
licz[j>>x & 1]++;
}
moves.insert({licz[0], licz[1], char(j)});
}
for(auto x: moves) {
ez_moves.push_back({get<0>(x) - get<1>(x), get<2>(x)});
}
int n;
cin >> n;
string s;
cin>>s;
for(int i = 0; i < 8*n; ++i) {
int bit = s[i] - '0';
cnt[bit]++;
}
int to_get = cnt[0] - cnt[1];
if(to_get % 2 == 1) {
cout << "NIE\n";
}
if(to_get > 0 && to_get <= n*2) {
while(to_get > 0) {
n--;
to_get-=2;
cout << "a";
}
while(n > 0) {
cout << "c";
n--;
}
return 0;
}
if(to_get > 0) {
cout << "NIE\n";
return 0;
}
to_get = -to_get;
if(to_get <= 4*n) {
while(to_get >= 4) {
to_get -= 4;
n--;
cout << "o";
}
while(to_get >= 2) {
to_get -= 2;
n--;
cout << "m";
}
while(n>0) {
cout<<"c";
n--;
}
return 0;
}
cout<<"NIE\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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | #include <bits/stdc++.h> using namespace std; int cnt[2]; /* * Ruchy - * * * */ int licz[2]; set<tuple<int, int, char>> moves; vector<pair<int, char>> ez_moves; int main() { ios_base::sync_with_stdio(0); cin.tie(0); for(int j = 97; j <= 96 + 26; ++j) { licz[0] = licz[1] = 0; for(int x = 0; x < 8; ++x) { licz[j>>x & 1]++; } moves.insert({licz[0], licz[1], char(j)}); } for(auto x: moves) { ez_moves.push_back({get<0>(x) - get<1>(x), get<2>(x)}); } int n; cin >> n; string s; cin>>s; for(int i = 0; i < 8*n; ++i) { int bit = s[i] - '0'; cnt[bit]++; } int to_get = cnt[0] - cnt[1]; if(to_get % 2 == 1) { cout << "NIE\n"; } if(to_get > 0 && to_get <= n*2) { while(to_get > 0) { n--; to_get-=2; cout << "a"; } while(n > 0) { cout << "c"; n--; } return 0; } if(to_get > 0) { cout << "NIE\n"; return 0; } to_get = -to_get; if(to_get <= 4*n) { while(to_get >= 4) { to_get -= 4; n--; cout << "o"; } while(to_get >= 2) { to_get -= 2; n--; cout << "m"; } while(n>0) { cout<<"c"; n--; } return 0; } cout<<"NIE\n"; return 0; } |
English