#include <bits/stdc++.h> using namespace std; char lit[10]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n,i,il=0; char a; lit[3]='b'; lit[4]='c'; lit[5]='g'; lit[6]='w'; cin >> n; for(i=1; i<=8*n; i++) { cin >> a; if(a=='1') il++; } if(il/n<3 || ceil((float)il/(float)n)>6) { cout << "NIE"; return 0; } for(i=1; i<=n; i++) { if(il%n==0) { cout << lit[il/n]; } else { int xd=il-(il/n)*n; if(xd+il/n>6) { cout << 'w'; il-=6-il/n; } else { cout << lit[xd+il/n]; il-=xd; } } } }
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; char lit[10]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n,i,il=0; char a; lit[3]='b'; lit[4]='c'; lit[5]='g'; lit[6]='w'; cin >> n; for(i=1; i<=8*n; i++) { cin >> a; if(a=='1') il++; } if(il/n<3 || ceil((float)il/(float)n)>6) { cout << "NIE"; return 0; } for(i=1; i<=n; i++) { if(il%n==0) { cout << lit[il/n]; } else { int xd=il-(il/n)*n; if(xd+il/n>6) { cout << 'w'; il-=6-il/n; } else { cout << lit[xd+il/n]; il-=xd; } } } } |