#include<bits/stdc++.h>
using namespace std;
char co[8];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
co[3]='a';
co[4]='c';
co[5]='k';
co[6]='w';
int n;
cin>>n;
string S;
cin>>S;
int g = 0;
for(int i = 0; i < S.size(); i ++)
{
if(S[i]=='1')
g++;
}
if( !(g >= 3*n && g <= 6*n) )
{
cout<<"NIE";
return 0;
}
int ile=n;
for(int i=1; i<=n; i++)
{
for(int i=3; i<=6; i++)
{
if(g-i >= 3*(ile-1) && g-i <= 6*(ile-1))
{
cout<<co[i];
g-=i;
break;
}
}
ile--;
}
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 | #include<bits/stdc++.h> using namespace std; char co[8]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); co[3]='a'; co[4]='c'; co[5]='k'; co[6]='w'; int n; cin>>n; string S; cin>>S; int g = 0; for(int i = 0; i < S.size(); i ++) { if(S[i]=='1') g++; } if( !(g >= 3*n && g <= 6*n) ) { cout<<"NIE"; return 0; } int ile=n; for(int i=1; i<=n; i++) { for(int i=3; i<=6; i++) { if(g-i >= 3*(ile-1) && g-i <= 6*(ile-1)) { cout<<co[i]; g-=i; break; } } ile--; } return 0; } |
English