#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 800005;
char res[7] = {'-', '-', '-', 'a', 'c', 'g', 'w'};
int n, x, i, l, r;
char t[N];
int main() {
scanf("%d", &n);
scanf("%s", t);
x = 0;
for (i=0;i<8*n;i++) if (t[i] == '1') x++;
if (x < 3 * n || x > 6 * n) {
printf("NIE\n");
return 0;
}
l = x / n;
r = x % n;
for (i=0;i<n;i++) {
if (r) {
printf("%c", res[l + 1]);
r--;
} else printf("%c", res[l]);
}
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 | #include <bits/stdc++.h> using namespace std; typedef vector<int> VI; typedef pair <int,int> ii; typedef long long LL; #define pb push_back const int INF = 2147483647; const int N = 800005; char res[7] = {'-', '-', '-', 'a', 'c', 'g', 'w'}; int n, x, i, l, r; char t[N]; int main() { scanf("%d", &n); scanf("%s", t); x = 0; for (i=0;i<8*n;i++) if (t[i] == '1') x++; if (x < 3 * n || x > 6 * n) { printf("NIE\n"); return 0; } l = x / n; r = x % n; for (i=0;i<n;i++) { if (r) { printf("%c", res[l + 1]); r--; } else printf("%c", res[l]); } printf("\n"); return 0; } |
English