#include<bits/stdc++.h>
using namespace std;
int n;
string s;
// minimalna # jedynek a -> 3
// c -> 4
// g -> 5
// maksymalna # jedynek w -> 6
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> s;
int l1 = 0;
for (int i = 0; i < 8 * n; i++)
l1 += (s[i] == '1');
if (l1 < 3 * n || l1 > 6 * n)
cout << "NIE\n";
else
{
if (l1 % 3 == 1){
l1 -= 4;
cout << "c";
n--;
}
if (l1 % 3 == 2){
l1 -= 5;
cout << "g";
n--;
}
while (n)
{
if (l1 < n * 6){
l1 -= 3;
n--;
cout << "a";
}
else{
l1 -= 6;
n--;
cout << "w";
}
}
cout << "\n";
}
return 0;
}
// Awwww
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 | #include<bits/stdc++.h> using namespace std; int n; string s; // minimalna # jedynek a -> 3 // c -> 4 // g -> 5 // maksymalna # jedynek w -> 6 int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> s; int l1 = 0; for (int i = 0; i < 8 * n; i++) l1 += (s[i] == '1'); if (l1 < 3 * n || l1 > 6 * n) cout << "NIE\n"; else { if (l1 % 3 == 1){ l1 -= 4; cout << "c"; n--; } if (l1 % 3 == 2){ l1 -= 5; cout << "g"; n--; } while (n) { if (l1 < n * 6){ l1 -= 3; n--; cout << "a"; } else{ l1 -= 6; n--; cout << "w"; } } cout << "\n"; } return 0; } // Awwww |
English