// Jan Burdzicki #include <bits/stdc++.h> using namespace std; const int MIN_ILOSC_1 = 3; const int MAX_ILOSC_1 = 6; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; string s; cin >> s; int ilosc_1 = 0; for(auto& x : s) { if(x == '1') { ilosc_1++; } } string mapka = "pxvw"; if(3 * n <= ilosc_1 && ilosc_1 <= 6 * n) { vector <int> liczby(n, ilosc_1 / n); ilosc_1 %= n; for(int i = 0; i < n; i++) { int do_dodania = min(MAX_ILOSC_1 - liczby[i], ilosc_1); liczby[i] += do_dodania; ilosc_1 -= do_dodania; } for(auto& x : liczby) { cout << mapka[x - MIN_ILOSC_1]; } cout << "\n"; } else { cout << "NIE\n"; } 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 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 | // Jan Burdzicki #include <bits/stdc++.h> using namespace std; const int MIN_ILOSC_1 = 3; const int MAX_ILOSC_1 = 6; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; string s; cin >> s; int ilosc_1 = 0; for(auto& x : s) { if(x == '1') { ilosc_1++; } } string mapka = "pxvw"; if(3 * n <= ilosc_1 && ilosc_1 <= 6 * n) { vector <int> liczby(n, ilosc_1 / n); ilosc_1 %= n; for(int i = 0; i < n; i++) { int do_dodania = min(MAX_ILOSC_1 - liczby[i], ilosc_1); liczby[i] += do_dodania; ilosc_1 -= do_dodania; } for(auto& x : liczby) { cout << mapka[x - MIN_ILOSC_1]; } cout << "\n"; } else { cout << "NIE\n"; } return 0; } |