#include <bits/stdc++.h> using namespace std; int n; string s; void solve() { int b = 0; for(int i=0;i<n*8;i++){ if(s[i]=='1'){ b++; } } if(b<n*3 || b >n*6) { cout<<"NIE\n"; return; } b-=3*n; int ile = 0; while(b>=3) { cout<<'o'; ile++; b-=3; } while(b>=2) { cout<<'g'; ile++; b-=2; } while(b>=1) { cout<<'c'; ile++; b-=1; } while(ile<n){ cout<<'a'; ile++; } return; } int main() { ios_base::sync_with_stdio(false); cin>>n>>s; solve(); //cout<<solve() <<"\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 | #include <bits/stdc++.h> using namespace std; int n; string s; void solve() { int b = 0; for(int i=0;i<n*8;i++){ if(s[i]=='1'){ b++; } } if(b<n*3 || b >n*6) { cout<<"NIE\n"; return; } b-=3*n; int ile = 0; while(b>=3) { cout<<'o'; ile++; b-=3; } while(b>=2) { cout<<'g'; ile++; b-=2; } while(b>=1) { cout<<'c'; ile++; b-=1; } while(ile<n){ cout<<'a'; ile++; } return; } int main() { ios_base::sync_with_stdio(false); cin>>n>>s; solve(); //cout<<solve() <<"\n"; return 0; } |