#define make_pair mp #define emplace_back pb #include <bits/stdc++.h> using namespace std; mt19937 mt_rand(time(0)); const int N = 1e5 + 5; int n; char s[8 * N], c[10]; int main() { c[3] = 'a'; c[4] = 'c'; c[5] = 'g'; c[6] = 'o'; scanf("%d", &n); scanf("%s", s); int cnt = 0; for(int i=0;i<8*n;i++) { if(s[i] == '1') cnt++; } if(cnt < 3 * n || cnt > 6 * n) { printf("NIE\n"); return 0; } int x = cnt / n; int xx = x * n; for(int i=xx+1;i<=cnt;i++) printf("%c", c[x+1]); int m = n - (cnt - xx); for(int i=1;i<=m;i++) printf("%c", c[x]); 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 | #define make_pair mp #define emplace_back pb #include <bits/stdc++.h> using namespace std; mt19937 mt_rand(time(0)); const int N = 1e5 + 5; int n; char s[8 * N], c[10]; int main() { c[3] = 'a'; c[4] = 'c'; c[5] = 'g'; c[6] = 'o'; scanf("%d", &n); scanf("%s", s); int cnt = 0; for(int i=0;i<8*n;i++) { if(s[i] == '1') cnt++; } if(cnt < 3 * n || cnt > 6 * n) { printf("NIE\n"); return 0; } int x = cnt / n; int xx = x * n; for(int i=xx+1;i<=cnt;i++) printf("%c", c[x+1]); int m = n - (cnt - xx); for(int i=1;i<=m;i++) printf("%c", c[x]); return 0; } |