/*#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops")*/ #include <bits/stdc++.h> #define bit(n, i) (((n)>>(i))&1) #define cat(x) cout << #x << " = " << x << "\n" #define pb push_back #define mp make_pair #define se second #define fi first #define inf 2000000000 #define llinf 2000000000000000000LL #define forn(i, a, b) for(ll i = (a); i <= (b); ++i) #define all(x) (x).begin(), (x).end() #define ppc(x) __builtin_popcount(x) using namespace std; typedef long long ll; typedef double ld; typedef pair<int, int> i2; typedef vector<int> vi; typedef vector<ll> vll; const int N = 5e5+9; bool vis[N]; const char C[] = {'a', 'c', 'g', 'o'}; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int ones = 0; forn(i, 1, 8*n) { char c; cin >> c; if(c == '1') ones++; } int k = ones-3*n; if(k < 0) { cout << "NIE"; return 0; } int l = k/3+(k % 3 == 0 ? 0 : 1); if(l > n) { cout << "NIE"; return 0; } if(k % 3 == 0) { forn(i, 1, l) cout << C[3]; forn(i, l+1, n) cout << C[0]; } else { cout << C[k % 3]; forn(i, 1, l-1) cout << C[3]; forn(i, l+1, n) cout << C[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 63 64 | /*#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops")*/ #include <bits/stdc++.h> #define bit(n, i) (((n)>>(i))&1) #define cat(x) cout << #x << " = " << x << "\n" #define pb push_back #define mp make_pair #define se second #define fi first #define inf 2000000000 #define llinf 2000000000000000000LL #define forn(i, a, b) for(ll i = (a); i <= (b); ++i) #define all(x) (x).begin(), (x).end() #define ppc(x) __builtin_popcount(x) using namespace std; typedef long long ll; typedef double ld; typedef pair<int, int> i2; typedef vector<int> vi; typedef vector<ll> vll; const int N = 5e5+9; bool vis[N]; const char C[] = {'a', 'c', 'g', 'o'}; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int ones = 0; forn(i, 1, 8*n) { char c; cin >> c; if(c == '1') ones++; } int k = ones-3*n; if(k < 0) { cout << "NIE"; return 0; } int l = k/3+(k % 3 == 0 ? 0 : 1); if(l > n) { cout << "NIE"; return 0; } if(k % 3 == 0) { forn(i, 1, l) cout << C[3]; forn(i, l+1, n) cout << C[0]; } else { cout << C[k % 3]; forn(i, 1, l-1) cout << C[3]; forn(i, l+1, n) cout << C[0]; } return 0; } |