#include <bits/stdc++.h>
using namespace std;
void imax(int &a, int b){
a=max(a, b);
}
void imin(int &a, int b){
a=min(a, b);
}
void lmax(long long &a, long long b){
a=max(a, b);
}
void lmin(long long &a, long long b){
a=min(a, b);
}
/*
WARNING: I'm using strange bracket style!
*/
const int SIZE=1000000;
map <int, int> M;
bool DP[SIZE];
int x, n;
string s;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
for (char i='a'; i<='z'; i++)
x=__builtin_popcount(i), M[x]==0 ? M[x]=i:M[x]=M[x];
cin>>n>>s, x=0;
for (auto i: s)
x+=(i=='1' ? 1:0);
if (x>6*n || x<3*n)
return cout<<"NIE\n", 0;
while (x!=0)
for (auto i: M)
if (x-i.first>=3*(n-1) && x-i.first<=6*(n-1))
{
cout<<char(i.second), n--, x-=i.first;
continue;
}
cout<<"\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 | #include <bits/stdc++.h> using namespace std; void imax(int &a, int b){ a=max(a, b); } void imin(int &a, int b){ a=min(a, b); } void lmax(long long &a, long long b){ a=max(a, b); } void lmin(long long &a, long long b){ a=min(a, b); } /* WARNING: I'm using strange bracket style! */ const int SIZE=1000000; map <int, int> M; bool DP[SIZE]; int x, n; string s; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); for (char i='a'; i<='z'; i++) x=__builtin_popcount(i), M[x]==0 ? M[x]=i:M[x]=M[x]; cin>>n>>s, x=0; for (auto i: s) x+=(i=='1' ? 1:0); if (x>6*n || x<3*n) return cout<<"NIE\n", 0; while (x!=0) for (auto i: M) if (x-i.first>=3*(n-1) && x-i.first<=6*(n-1)) { cout<<char(i.second), n--, x-=i.first; continue; } cout<<"\n"; return 0; } |
English