#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 5;
int type[MAX_N];
int on_count;
int main() {
cin.tie(0); ios_base::sync_with_stdio(false);
int n; cin >> n;
for(int i = 0; i < 8*n; i++) {
char c; cin >> c;
if(c == '1') on_count++;
}
if(on_count < 3*n || on_count > 6*n) {
cout << "NIE";
return 0;
}
on_count -= 3*n;
char letters[4] = { 'a', 'c', 'g', 'o' };
int type, cnt;
type = on_count / n;
cnt = on_count % n;
for(int i = 0; i < cnt; i++) {
cout << letters[type+1];
}
for(int i = 0; i < n-cnt; i++) {
cout << letters[type];
}
}
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 | #include <bits/stdc++.h> using namespace std; const int MAX_N = 1e5 + 5; int type[MAX_N]; int on_count; int main() { cin.tie(0); ios_base::sync_with_stdio(false); int n; cin >> n; for(int i = 0; i < 8*n; i++) { char c; cin >> c; if(c == '1') on_count++; } if(on_count < 3*n || on_count > 6*n) { cout << "NIE"; return 0; } on_count -= 3*n; char letters[4] = { 'a', 'c', 'g', 'o' }; int type, cnt; type = on_count / n; cnt = on_count % n; for(int i = 0; i < cnt; i++) { cout << letters[type+1]; } for(int i = 0; i < n-cnt; i++) { cout << letters[type]; } } |
English