Advertisement
pb_jiang

cf379d ac

Jan 2nd, 2023 (edited)
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.45 KB | None | 0 0
  1. #include <assert.h>
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. #define dbg(...) logger(#__VA_ARGS__, __VA_ARGS__)
  5. template <typename... Args> void logger(string vars, Args &&... values)
  6. {
  7.     cerr << vars << " = ";
  8.     string delim = "";
  9.     (..., (cerr << delim << values, delim = ", "));
  10.     cerr << endl;
  11. }
  12.  
  13. template <class T> inline auto vv(int m) { return vector<vector<T>>(m, vector<T>(m)); }
  14. template <class T> inline auto vv(int m, int n) { return vector<vector<T>>(m, vector<T>(n)); }
  15. template <class T, T init> inline auto vv(int m) { return vector<vector<T>>(m, vector<T>(m, init)); }
  16. template <class T, T init> inline auto vv(int m, int n) { return vector<vector<T>>(m, vector<T>(n, init)); }
  17.  
  18. template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
  19.  
  20. using ll = long long;
  21. using pii = pair<int, int>;
  22. using vl = vector<ll>;
  23. using vi = vector<int>;
  24.  
  25. int main(int argc, char **argv)
  26. {
  27.     int k, x, n, m;
  28.     cin >> k >> x >> n >> m;
  29.     ll a1 = 1, a2 = 1, a12 = 1, a21 = 0, a22 = 0;
  30.     ll b1 = 1, b2 = 2, b12 = 1, b21 = 1, b22 = 0;
  31.     for (int i = 5; i <= k; ++i) {
  32.         ll c1 = a1 + b1, c2 = a2 + b2;
  33.         ll c12 = a12 + b12, c21 = a21 + b21 + ((i + 1) % 2);
  34.         ll c22 = 0;
  35.         switch (i) {
  36.             case 3:
  37.                 c22 = 1;
  38.                 break;
  39.             default:
  40.                 c22 = a22 + b22 + (i % 2);
  41.                 break;
  42.         }
  43.         a1 = b1, a2 = b2, a12 = b12, a21 = b21, a22 = b22;
  44.         b1 = c1, b2 = c2, b12 = c12, b21 = c21, b22 = c22;
  45.         dbg(i, b21);
  46.     }
  47.     if (k == 3) {
  48.         b1 = a1, b2 = a2, b12 = a12, b21 = a21, b22 = a22;
  49.     }
  50.     if (k == 4) {
  51.         // nothing
  52.     }
  53.  
  54.     string s1, s2;
  55.     for (int i = 0; i <= n / 2; ++i) {
  56.         s2 = "";
  57.         for (int j = 0; j <= m / 2; ++j) {
  58.             if (x == i * b1 + j * b2) {
  59.                 dbg(i, b1, j, b2, i * b1 + j * b2, x);
  60.                 dbg(s1, s2);
  61.                 s1 += string(n - s1.size(), 'D');
  62.                 s2 += string(m - s2.size(), 'D');
  63.                 cout << s1 << '\n' << s2 << '\n';
  64.                 return 0;
  65.             } else if (x == i * b1 + j * b2 + b12 && i * 2 + 1 <= n && j * 2 + 1 <= m) {
  66.                 dbg(i, b1, j, b2, b12, i * b1 + j * b2 + b12, x);
  67.                 s1 += string(n - 1 - s1.size(), 'D');
  68.                 s2 += string(m - 1 - s2.size(), 'D');
  69.                 s1 += 'A';
  70.                 s2 = 'C' + s2;
  71.                 cout << s1 << '\n' << s2 << '\n';
  72.                 return 0;
  73.             } else if (x == i * b1 + j * b2 + b21 && i * 2 + 1 <= n && j * 2 + 1 <= m) {
  74.                 dbg(i, b1, j, b2, b21, i * b1 + j * b2 + b21, x);
  75.                 s1 += string(n - 1 - s1.size(), 'D');
  76.                 s2 += string(m - 1 - s2.size(), 'D');
  77.                 s1 = 'C' + s1;
  78.                 s2 += 'A';
  79.                 cout << s1 << '\n' << s2 << '\n';
  80.                 return 0;
  81.             } else if (x == i * b1 + j * b2 + b12 + b21 + b22 && i * 2 + 2 <= n && j * 2 + 2 <= m) {
  82.                 dbg(i, b1, j, b2, b12, b21, b22, i * b1 + j * b2 + b12 + b21 + b22, x);
  83.                 s1 += string(n - 2 - s1.size(), 'D');
  84.                 s2 += string(m - 2 - s2.size(), 'D');
  85.                 s1 = 'C' + s1 + 'A';
  86.                 s2 = 'C' + s2 + 'A';
  87.                 cout << s1 << '\n' << s2 << '\n';
  88.                 return 0;
  89.             } else if (x == i * b1 + j * b2 + b12 + b22 && i * 2 + 1 <= n && j * 2 + 2 <= m) {
  90.                 s1 += string(n - 1 - s1.size(), 'D');
  91.                 s2 += string(m - 2 - s2.size(), 'D');
  92.                 s1 += 'A';
  93.                 s2 = 'C' + s2 + 'A';
  94.                 cout << s1 << '\n' << s2 << '\n';
  95.                 return 0;
  96.             } else if (x == i * b1 + j * b2 + b21 + b22 && i * 2 + 1 <= n && j * 2 + 2 <= m) {
  97.                 s1 += string(n - 1 - s1.size(), 'D');
  98.                 s2 += string(m - 2 - s2.size(), 'D');
  99.                 s1 = 'C' + s1;
  100.                 s2 = 'C' + s2 + 'A';
  101.                 cout << s1 << '\n' << s2 << '\n';
  102.                 return 0;
  103.             } else if (x == i * b1 + j * b2 + b22 && j * 2 + 2 <= m) {
  104.                 s1 += string(n - s1.size(), 'D');
  105.                 s2 += string(m - 2 - s2.size(), 'D');
  106.                 s2 = 'C' + s2 + 'A';
  107.                 cout << s1 << '\n' << s2 << '\n';
  108.                 return 0;
  109.             }
  110.             s2 += "AC";
  111.         }
  112.         s1 += "AC";
  113.     }
  114.     cout << "Happy new year!" << endl;
  115.     return 0;
  116. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement