//Autor: Szymon Nowak #include <iostream> using namespace std; int main() { int n; cin>>n; char tablica[8*n]; int ile_jedynek=0; for(int i=0;i<8*n;i++) { cin>>tablica[i]; if(tablica[i]=='1') ile_jedynek++; } int ciag[n]; if(ile_jedynek<3*n || ile_jedynek>6*n) cout<<"NIE"<<"\n"; else { for(int i=0;i<n;i++) { ciag[i]=3; ile_jedynek-=3; } int j=0; while(ile_jedynek>0) { if(ciag[j]==6) j++; ciag[j]+=1; ile_jedynek--; } } for(int i=0;i<n;i++) { switch(ciag[i]) { case 3: cout<<"a"; break; case 4: cout<<"c"; break; case 5: cout<<"m"; break; case 6: cout<<"o"; break; } } 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 | //Autor: Szymon Nowak #include <iostream> using namespace std; int main() { int n; cin>>n; char tablica[8*n]; int ile_jedynek=0; for(int i=0;i<8*n;i++) { cin>>tablica[i]; if(tablica[i]=='1') ile_jedynek++; } int ciag[n]; if(ile_jedynek<3*n || ile_jedynek>6*n) cout<<"NIE"<<"\n"; else { for(int i=0;i<n;i++) { ciag[i]=3; ile_jedynek-=3; } int j=0; while(ile_jedynek>0) { if(ciag[j]==6) j++; ciag[j]+=1; ile_jedynek--; } } for(int i=0;i<n;i++) { switch(ciag[i]) { case 3: cout<<"a"; break; case 4: cout<<"c"; break; case 5: cout<<"m"; break; case 6: cout<<"o"; break; } } return 0; } |