Submission #887827

# Submission time Handle Problem Language Result Execution time Memory
887827 2023-12-15T09:26:53 Z vjudge1 Tents (JOI18_tents) C++17
100 / 100
132 ms 70996 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define u_map unordered_map
const int maxn = 3e3 + 5, mod = 1e9 + 7;

ll dp[maxn][maxn];

ll c(int a) {
	return (a * (a - 1) / 2) % mod; 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i <= n; i++) {
    	dp[i][0] = 1;
    }
    for (int i = 0; i <= m; i++) {
    	dp[0][i] = 1;
    }
    for (int i = 1; i <= n; i++) {
    	for (int j = 1; j <= m; j++) {
    		dp[i][j] = dp[i][j - 1];
    		dp[i][j] = (dp[i][j] + (((i) * 4 % mod) * dp[i - 1][j - 1] % mod)) % mod;
    		dp[i][j] = (dp[i][j] + (((i) * (j - 1) % mod) * dp[i - 1][j - 2] % mod)) % mod;
    		dp[i][j] = (dp[i][j] + c(i) * dp[i - 2][j - 1] % mod) % mod;
       	}
    }
    cout << (dp[n][m] - 1 + mod) % mod;
    return 0;
}
    // dp[1][1] = 4;
    // dp[2][1] = 9;
    // dp[1][2] = 9;
    // dp[1][3] = 15;
    // dp[3][1] = 15;
    // dp[2][3];
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 6500 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 6488 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 2 ms 8540 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 2 ms 8540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 6500 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 6488 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 2 ms 8540 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 2 ms 8540 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 11 ms 55816 KB Output is correct
15 Correct 85 ms 66140 KB Output is correct
16 Correct 6 ms 6488 KB Output is correct
17 Correct 19 ms 16988 KB Output is correct
18 Correct 25 ms 29300 KB Output is correct
19 Correct 97 ms 70232 KB Output is correct
20 Correct 79 ms 57948 KB Output is correct
21 Correct 52 ms 39760 KB Output is correct
22 Correct 54 ms 51804 KB Output is correct
23 Correct 34 ms 70480 KB Output is correct
24 Correct 132 ms 70996 KB Output is correct
25 Correct 100 ms 62180 KB Output is correct
26 Correct 114 ms 68188 KB Output is correct
27 Correct 127 ms 70488 KB Output is correct