#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define MAXN 100000
char B[8 * MAXN+5];
string letter_with_bits[8] = {
"wrong",
"wrong",
"wrong",
"01100001", // a - 3
"01100011", // c - 4
"01100111", // g - 5
"01110111", // w - 6
};
string letters = " acgw";
int main() {
int n;
scanf("%d", &n);
scanf("%s", B);
int e8n = 8*n;
int ile[2] = {0,0};
for (int i=0; i < e8n; i++)
{
ile[B[i]-'0']++;
}
//printf("ile[0]=%d, ile[1]=%d\n", ile[0], ile[1]);
if (!(n*3 <= ile[1] && ile[1] <= n*6))
{
printf("NIE\n");
return 0;
}
vector<int> out(n, 3);
ile[1] -= n*3;
// tyle jedynek pozostalo
for (int i=0; i < n; i++)
{
if (ile[1] == 0) break;
if (ile[1] >= 3)
{
out[i] = 6;
ile[1] -= 3;
continue;
}
out[i] = 3 + ile[1]; // 4 lub 5
ile[1] = 0;
}
for (int i=0; i < n; i++)
{
printf("%c", letters[out[i]]);
}
printf("\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 | #include <bits/stdc++.h> using namespace std; #define LL long long #define MAXN 100000 char B[8 * MAXN+5]; string letter_with_bits[8] = { "wrong", "wrong", "wrong", "01100001", // a - 3 "01100011", // c - 4 "01100111", // g - 5 "01110111", // w - 6 }; string letters = " acgw"; int main() { int n; scanf("%d", &n); scanf("%s", B); int e8n = 8*n; int ile[2] = {0,0}; for (int i=0; i < e8n; i++) { ile[B[i]-'0']++; } //printf("ile[0]=%d, ile[1]=%d\n", ile[0], ile[1]); if (!(n*3 <= ile[1] && ile[1] <= n*6)) { printf("NIE\n"); return 0; } vector<int> out(n, 3); ile[1] -= n*3; // tyle jedynek pozostalo for (int i=0; i < n; i++) { if (ile[1] == 0) break; if (ile[1] >= 3) { out[i] = 6; ile[1] -= 3; continue; } out[i] = 3 + ile[1]; // 4 lub 5 ile[1] = 0; } for (int i=0; i < n; i++) { printf("%c", letters[out[i]]); } printf("\n"); return 0; } |
English