#include <bits/stdc++.h> #ifdef LOC #include "debuglib.h" #else #define deb(...) #define DBP(...) #endif using namespace std; using ll = long long; using vi = vector<int>; using pii = pair<int, int>; #define pb push_back #define mp make_pair #define x first #define y second #define rep(i, b, e) for (int i = (b); i < (e); i++) #define each(a, x) for (auto& a : (x)) #define all(x) (x).begin(), (x).end() #define sz(x) int((x).size()) void step(string& out, const string& s, ll repeat) { if (s.empty() || repeat == 0) return; if (repeat == 1) { out += s; } else if (repeat > 9) { string tmp; step(tmp, s, repeat/9); step(out, tmp, 9); step(out, s, repeat%9); } else { out.pb(char(repeat+'0')); if (sz(s) > 1) out.pb('['); out += s; if (sz(s) > 1) out.pb(']'); } } void withoutLeftSide(string& out, ll n) { if (n < 3) { for (ll i = n; i > 0; i--) { step(out, "A", i); step(out, "EC", i-1); step(out, "E", 1); } } else if (n%2 == 0) { step(out, "A", n); step(out, "EC", n-1); step(out, "E", 1); withoutLeftSide(out, n-1); } else { ll k = n/2-1; step(out, "AF", 1); string rec; withoutLeftSide(rec, k); step(out, rec, 2); step(out, "C", k*2); step(out, "BF", k); string stripe; step(stripe, "FD", k-1); step(stripe, "F", 1); step(stripe, "B", k); step(out, stripe, k); step(out, "FD", k*2); step(out, "F", 1); step(out, "B", k*2+1); step(out, "D", k+1); step(out, "BF", k+1); step(out, "B", 1); step(out, "D", k*2+2); step(out, "EA", k*2+2); step(out, "E", 1); } } string solve(ll n) { string out; withoutLeftSide(out, n); step(out, "C", n); return out; } int main() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); ll n; cin >> n; string ans = solve(n); #ifdef LOC deb(n, sz(ans)); assert(sz(ans) <= 150000); #endif cout << ans << '\n'; cout << flush; _Exit(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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | #include <bits/stdc++.h> #ifdef LOC #include "debuglib.h" #else #define deb(...) #define DBP(...) #endif using namespace std; using ll = long long; using vi = vector<int>; using pii = pair<int, int>; #define pb push_back #define mp make_pair #define x first #define y second #define rep(i, b, e) for (int i = (b); i < (e); i++) #define each(a, x) for (auto& a : (x)) #define all(x) (x).begin(), (x).end() #define sz(x) int((x).size()) void step(string& out, const string& s, ll repeat) { if (s.empty() || repeat == 0) return; if (repeat == 1) { out += s; } else if (repeat > 9) { string tmp; step(tmp, s, repeat/9); step(out, tmp, 9); step(out, s, repeat%9); } else { out.pb(char(repeat+'0')); if (sz(s) > 1) out.pb('['); out += s; if (sz(s) > 1) out.pb(']'); } } void withoutLeftSide(string& out, ll n) { if (n < 3) { for (ll i = n; i > 0; i--) { step(out, "A", i); step(out, "EC", i-1); step(out, "E", 1); } } else if (n%2 == 0) { step(out, "A", n); step(out, "EC", n-1); step(out, "E", 1); withoutLeftSide(out, n-1); } else { ll k = n/2-1; step(out, "AF", 1); string rec; withoutLeftSide(rec, k); step(out, rec, 2); step(out, "C", k*2); step(out, "BF", k); string stripe; step(stripe, "FD", k-1); step(stripe, "F", 1); step(stripe, "B", k); step(out, stripe, k); step(out, "FD", k*2); step(out, "F", 1); step(out, "B", k*2+1); step(out, "D", k+1); step(out, "BF", k+1); step(out, "B", 1); step(out, "D", k*2+2); step(out, "EA", k*2+2); step(out, "E", 1); } } string solve(ll n) { string out; withoutLeftSide(out, n); step(out, "C", n); return out; } int main() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); ll n; cin >> n; string ans = solve(n); #ifdef LOC deb(n, sz(ans)); assert(sz(ans) <= 150000); #endif cout << ans << '\n'; cout << flush; _Exit(0); } |