#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(...) begin(__VA_ARGS__) , end(__VA_ARGS__)
#define boost {ios_base::sync_with_stdio(false); cin.tie(); cout.tie();}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector <int> vi;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
constexpr ll nax = 2e5+6969, INF = 2e9+6969;
int n, k;
char lit[10];
int main()
{
for(int i=0;i<10;i++) lit[i] = '.';
for(int i=1;i<=26;i++)
{
int tmp = __builtin_popcount(96 + i);
lit[tmp] = (char)(i + 96);
}
// for(int i=0;i<10;i++) printf("%c ", lit[i]);
// puts("");
scanf("%d", &n);
int ones = 0;
for(int i=0;i<n * 8;i++)
{
char x;
cin >> x;
if(x == '1') ones++;
}
if(ones < 3 * n || ones > 6 * n)
{
puts("NIE");
return 0;
}
for(int i=0;i<n;i++)
{
int tmp = ones - 3 * i - 6 * (n - i - 1);
if(tmp >= 3 && tmp <= 6)
{
for(int j = 0; j < i; j++) printf("%c", lit[3]);
ones -= 3 * i;
for(int j = i; j < n - 1; j++) printf("%c", lit[6]);
ones -= 6 * (n - i - 1);
printf("%c\n", lit[ones]);
return 0;
}
}
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 53 54 55 56 57 58 59 60 61 62 | #define pb push_back #define mp make_pair #define fi first #define se second #define all(...) begin(__VA_ARGS__) , end(__VA_ARGS__) #define boost {ios_base::sync_with_stdio(false); cin.tie(); cout.tie();} #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef vector <int> vi; typedef pair<int,int> PII; typedef pair<ll,ll> PLL; constexpr ll nax = 2e5+6969, INF = 2e9+6969; int n, k; char lit[10]; int main() { for(int i=0;i<10;i++) lit[i] = '.'; for(int i=1;i<=26;i++) { int tmp = __builtin_popcount(96 + i); lit[tmp] = (char)(i + 96); } // for(int i=0;i<10;i++) printf("%c ", lit[i]); // puts(""); scanf("%d", &n); int ones = 0; for(int i=0;i<n * 8;i++) { char x; cin >> x; if(x == '1') ones++; } if(ones < 3 * n || ones > 6 * n) { puts("NIE"); return 0; } for(int i=0;i<n;i++) { int tmp = ones - 3 * i - 6 * (n - i - 1); if(tmp >= 3 && tmp <= 6) { for(int j = 0; j < i; j++) printf("%c", lit[3]); ones -= 3 * i; for(int j = i; j < n - 1; j++) printf("%c", lit[6]); ones -= 6 * (n - i - 1); printf("%c\n", lit[ones]); return 0; } } return 0; } |
English