SHARE
    TWEET
    Vince14

    14165

    Mar 19th, 2023
    107
    0
    Never
    Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
    C++ 1.84 KB | Source Code | 0 0
    1. #include <iostream>
    2. #include <string>
    3. #include <cstring>
    4. #include <algorithm>
    5. #include <cmath>
    6. #include <vector>
    7. #include <set>
    8. #include <map>
    9. #include <stack>
    10. #include <queue>
    11. #include <deque>
    12. #include <unordered_map>
    13. #include <iomanip>
    14. #include <regex>
    15. #include <numeric>
    16. using namespace std;
    17. #define pii pair<long long , long long>
    18. #define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
    19. const long long dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
    20. const long long MAX = 100005;
    21. const long long MOD = 1000000009;
    22. int n, m, k;
    23. long long arr1[1005], arr2[1005];
    24. long long dp[1005][1005];
    25. long long dp2[1005][1005];
    26. void do_dp(){
    27. memset(dp2, 0, sizeof dp2);
    28. for(int i = 1; i <= n; i++){
    29. for(int j = 1; j <= m; j++){
    30. if(arr1[i] > arr2[j]){
    31. dp2[i][j] = dp[i - 1][j - 1];
    32. }
    33. }
    34. }
    35. }
    36. void update_dp(){
    37. for(int i = 0; i < 1005; i++){
    38. for(int j = 0; j < 1005; j++){
    39. dp[i][j] = dp2[i][j];
    40. }
    41. }
    42. for(int i = 0; i < n; i++){
    43. for(int j = 0; j < m; j++){
    44. dp[i + 1][j + 1] += dp[i][j + 1];
    45. dp[i + 1][j + 1] += dp[i + 1][j];
    46. dp[i + 1][j + 1] -= dp[i][j];
    47. dp[i + 1][j + 1] %= MOD;
    48. }
    49. }
    50. }
    51. int main() {
    52. //freopen("talent.in", "r", stdin);
    53. //freopen("talent.out", "w", stdout);
    54. FAST;
    55. cin >> n >> m >> k;
    56. for(int i = 1; i <= n; i++){
    57. cin >> arr1[i];
    58. }
    59. sort(arr1 + 1, arr1 + n + 1);
    60. for(int i = 1; i <= m; i++){
    61. cin >> arr2[i];
    62. }
    63. sort(arr2 + 1, arr2 + m + 1);
    64. fill(&dp[0][0], &dp[0][0] + 1005 * 1005, 1);
    65. for (int i = 0; i < k; i++)
    66. {
    67. do_dp();
    68. update_dp();
    69. }
    70. while(dp[n][m] < 0){
    71. dp[n][m] += MOD;
    72. }
    73. cout << dp[n][m];
    74. }
    Advertisement
    Add Comment
    Please, Sign In to add comment
    Public Pastes
    We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
    Not a member of Pastebin yet?
    Sign Up, it unlocks many cool features!

    AltStyle によって変換されたページ (->オリジナル) /