#include <algorithm> #include <cstdio> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define INT(x) int x; scanf("%d", &x) const char C[5] = "acgo"; int main() { INT(n); scanf("\n"); int ones = 0, n8 = n << 3; REP(i,n8) ones += getchar() == '1'; if (ones < 3 * n || ones > 6 * n) { printf("NIE\n"); return 0; } ones -= 3 * n; REP(i,n) { int x = min(ones, 3); putchar(C[x]); ones -= x; } putchar('\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 | #include <algorithm> #include <cstdio> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define INT(x) int x; scanf("%d", &x) const char C[5] = "acgo"; int main() { INT(n); scanf("\n"); int ones = 0, n8 = n << 3; REP(i,n8) ones += getchar() == '1'; if (ones < 3 * n || ones > 6 * n) { printf("NIE\n"); return 0; } ones -= 3 * n; REP(i,n) { int x = min(ones, 3); putchar(C[x]); ones -= x; } putchar('\n'); } |