#include<bits/stdc++.h> using namespace std; int main () { ios_base::sync_with_stdio(0); int n, l1 = 0, l0; string s; cin>>n>>s; for (auto i : s) if (i == '1') ++l1; l0 = 8*n - l1; if (l1 / n < 3 || l1 / n > 6) cout<<"NIE"; else if (l0 > l1) { string a ((l0-l1)/2, 'a'); string c (n - a.size(), 'c'); cout<<a+c; } else if (l0 == l1) { string c (n, 'c'); cout<<c; } else { string o ((l1-l0)/4, 'o'); string g; if ((l1-l0)%4 != 0) g = "g"; else g = ""; string c (n - o.size() - g.size(), 'c'); cout<<c + g + o; } 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 | #include<bits/stdc++.h> using namespace std; int main () { ios_base::sync_with_stdio(0); int n, l1 = 0, l0; string s; cin>>n>>s; for (auto i : s) if (i == '1') ++l1; l0 = 8*n - l1; if (l1 / n < 3 || l1 / n > 6) cout<<"NIE"; else if (l0 > l1) { string a ((l0-l1)/2, 'a'); string c (n - a.size(), 'c'); cout<<a+c; } else if (l0 == l1) { string c (n, 'c'); cout<<c; } else { string o ((l1-l0)/4, 'o'); string g; if ((l1-l0)%4 != 0) g = "g"; else g = ""; string c (n - o.size() - g.size(), 'c'); cout<<c + g + o; } return 0; } |