#include <bits/stdc++.h> using namespace std; constexpr int dl = 8; constexpr int maxz = 5; constexpr int maxj = 6; main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; string ciag; cin >> ciag; const int maz = n*5; const int miz = n*2; int ilez = 0; for(int i = 0; i < n*dl; ++i) { if(ciag[i] == '0') { ++ilez; } } if(ilez > maz || ilez < miz) { cout << "NIE"; return 0; } for(int i = 0; i < n; ++i) { int j = 0; int ile = 0; int ilej = 0; while(ile < dl) { if(ciag[j] == '0' && ilez < maxz) { ciag[j] = 'x'; ++ile; } if(ciag[j] == '1' && ilej < maxj) { ciag[j] = 'x'; ++ilej; ++ile; } ++j; if(j <= n*dl) { j = 0; } } if(ilej == 3) { cout << "a"; } if(ilej == 4) { cout << "c"; } if(ilej == 5) { cout << "g"; } if(ilej == 6) { cout << "o"; } } }
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 | #include <bits/stdc++.h> using namespace std; constexpr int dl = 8; constexpr int maxz = 5; constexpr int maxj = 6; main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; string ciag; cin >> ciag; const int maz = n*5; const int miz = n*2; int ilez = 0; for(int i = 0; i < n*dl; ++i) { if(ciag[i] == '0') { ++ilez; } } if(ilez > maz || ilez < miz) { cout << "NIE"; return 0; } for(int i = 0; i < n; ++i) { int j = 0; int ile = 0; int ilej = 0; while(ile < dl) { if(ciag[j] == '0' && ilez < maxz) { ciag[j] = 'x'; ++ile; } if(ciag[j] == '1' && ilej < maxj) { ciag[j] = 'x'; ++ilej; ++ile; } ++j; if(j <= n*dl) { j = 0; } } if(ilej == 3) { cout << "a"; } if(ilej == 4) { cout << "c"; } if(ilej == 5) { cout << "g"; } if(ilej == 6) { cout << "o"; } } } |