Advertisement
ke_timofeeva7

Untitled

Mar 14th, 2022
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.56 KB | None | 0 0
  1. /*
  2. ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⣠⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⢀⣠⡯⠀⠀⠀⢠⡐⠀⠀⠀⠀⠀
  3. ⠀⠀⠀⢀⣤⠔⠂⠀⠀⠀⢤⣤⣤⣤⣄⣀⣀⣀⣀⡀⠀⢀⣀⣀⣀⡀⠀⠀⠀⢀⢀⣀⣠⣤⣴⣶⣾⠉⠉⠙⣶⠂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⣰⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀
  4. ⠀⠀⠰⣿⣷⣾⣿⣷⣴⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⠉⠛⢿⣿⣿⣿⣿⣿⣿⣿⠿⠿⣿⣶⣿⣿⣿⣿⣤⣂⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⣤⣤⣤⣴⣦⣾⣿⣿⣿⣶⣦⣴⣶⣶⠀
  5. ⠀⠀⠀⣿⣿⣿⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⣤⣶⣶⣿⣿⣿⣿⣿⣿⣿⣯⣤⣤⣿⡿⠿⠿⠿⠛⠛⠛⠛⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣽⣿⣿⡟⢻⣿⣿⣿⡟⣿⣿⣿⣿⠉⠉⠁⠀
  6. ⠀⠀⠀⣹⣟⣿⣦⠈⠻⠋⢉⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⣿⣿⣠⣾⣿⣿⣏⣤⣾⣿⣿⣿⡆⠀
  7. ⠀⠀⢀⣿⣿⣿⣿⣦⠀⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠟⢿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡧⠀
  8. ⠀⠀⢸⣿⣿⣿⣿⣿⡀⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡈⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⡄⠀
  9. ⠀⠀⠈⠿⠿⠁⣿⣿⣿⠎⠻⣯⠉⠉⠉⠈⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⢹⣿⢻⠉⠉⠁⠈⠻⢦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠁⠉⠙⠛⠛⢿⣿⠟⠋⠁⠀⠀⠀⠈⠀
  10. ⠀⠀⠀⠀⠀⠀⢹⣿⡟⠀⠀⠈⠳⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⠞⠀⠀⠀⠀⠀⠀⠙⠳⠤⠤⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠁⠀⠀⠀⠀⠀⠸⣿⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⠀
  11. ⠀⠀⠀⠀⠀⠀⢈⡟⠇⠀⠀⠀⠀⠈⠁⠤⠤⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣶⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⢹⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  12. ⠀⠀⠀⠀⠀⠀⠀⠙⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⠂⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⡘⡀⠀
  13. ⠀⠀⠀⠀⠀⠀ ⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  14. */
  15.  
  16. #include <iostream>
  17. #include <string>
  18. #include <sstream>
  19. #include <vector>
  20. #include <cmath>
  21. #include <algorithm>
  22. #include <memory.h>
  23. #include <stdio.h>
  24. #include <stack>
  25. #include <deque>
  26. #include <queue>
  27. #include <set>
  28. #include <iterator>
  29. #include <map>
  30. #include <iomanip>
  31. #include <unordered_set>
  32. #include <array>
  33. #include <random>
  34. #include <ctime>
  35. #include <chrono>
  36. #include <cstdlib>
  37. #define int long long
  38. #define pb push_back
  39. #define fir first
  40. #define sec second
  41. #define double long double
  42. #define endl "\n"
  43. #define un unsigned
  44. #define INF 1000000000000009
  45. #define EPS 0.0000000001
  46. #define pii pair<int, int>
  47. #define all(v) v.begin(), v.end()
  48. using namespace std;
  49.  
  50. const int N = 300009, MOD = 1e9+7, R = 1 << 20, logn = 19, ABC = 26;
  51.  
  52. mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
  53.  
  54. signed main()
  55. {
  56. ios_base::sync_with_stdio(false);
  57. cin.tie(0);
  58. cout.tie(0);
  59. cout.precision(20);
  60.  
  61. int n, k, x;
  62. cin >> n >> k >> x;
  63.  
  64. if (n <= 2)
  65. {
  66. cout << 0;
  67. return 0;
  68. }
  69.  
  70. vector<vector<vector<vector<int>>>> dp(n + 2, vector<vector<vector<int>>>(k + 2, vector<vector<int>>(x + 2, vector<int>(3, 0))));
  71.  
  72. for (int i = 1; i <= x; i++)
  73. {
  74. dp[2][0][i][2] = 1; // 2 -- равны
  75.  
  76. for (int j = i + 1; j <= x; j++)
  77. dp[2][0][i][1]++; // 1 -- последняя выше
  78. for (int j = 1; j < i; j++)
  79. dp[2][0][i][0]++; // 0 -- последняя ниже
  80. }
  81.  
  82. for (int len = 3; len <= n; len++)
  83. {
  84. for (int cnt = 0; cnt <= k + 1; cnt++)
  85. {
  86. for (int height = 1; height <= x; height++)
  87. {
  88. for (int last = 0; last <= 2; last++)
  89. {
  90. if (last == 0)
  91. {
  92. for (int i = 1; i < height; i++)
  93. {
  94. dp[len][cnt][i][last] += dp[len - 1][cnt][height][0] + dp[len - 1][cnt][height][2];
  95.  
  96. if (cnt)
  97. dp[len][cnt][i][last] += dp[len - 1][cnt - 1][height][1];
  98. }
  99. }
  100. else if (last == 1)
  101. {
  102. for (int i = height + 1; i <= x; i++)
  103. {
  104. dp[len][cnt][i][last] += dp[len - 1][cnt][height][0] + dp[len - 1][cnt][height][1] + dp[len - 1][cnt][height][2];
  105. }
  106. }
  107. else
  108. {
  109. dp[len][cnt][height][last] += dp[len - 1][cnt][height][0] + dp[len - 1][cnt][height][1] + dp[len - 1][cnt][height][2];
  110. }
  111.  
  112. dp[len][cnt][height][last] %= MOD;
  113. }
  114. }
  115. }
  116. }
  117.  
  118. int ans = 0;
  119.  
  120. for (int i = 1; i <= x; i++)
  121. for (int last = 0; last <= 2; last++)
  122. ans += dp[n][k][i][last];
  123.  
  124. cout << ans;
  125. return 0;
  126. }
  127.  
  128. /*
  129.  
  130. */
  131.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement