#include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin>>n;
string str; cin>>str;
int count = 0;
for(int i = 0; i < 8*n; i++)if(str[i] == '1')count++;
if(count < 3*n || count > 6*n){
cout<<"NIE\n";
}else{
vector<int> ans(n, 3);
count -= 3*n;
for(int i = 0; i < n; i++){
ans[i] += min(3, count);
count -= (ans[i] - 3);
}
string txt = "";
for(int i = 0; i < n; i++){
if(ans[i] == 3){
txt += "a";
}else if(ans[i] == 4){
txt += "c";
}else if(ans[i] == 5){
txt += "g";
}else if(ans[i] == 6){
txt += "o";
}
}
cout<<txt<<"\n";
}
}
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 | #include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; string str; cin>>str; int count = 0; for(int i = 0; i < 8*n; i++)if(str[i] == '1')count++; if(count < 3*n || count > 6*n){ cout<<"NIE\n"; }else{ vector<int> ans(n, 3); count -= 3*n; for(int i = 0; i < n; i++){ ans[i] += min(3, count); count -= (ans[i] - 3); } string txt = ""; for(int i = 0; i < n; i++){ if(ans[i] == 3){ txt += "a"; }else if(ans[i] == 4){ txt += "c"; }else if(ans[i] == 5){ txt += "g"; }else if(ans[i] == 6){ txt += "o"; } } cout<<txt<<"\n"; } } |
English