# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1021211 |
2024-07-12T15:39:45 Z |
aufan |
Tents (JOI18_tents) |
C++17 |
|
161 ms |
71052 KB |
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
using namespace std;
const int mod = 1e9 + 7;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
vector<vector<int>> dp(n + 1, vector<int>(m + 1));
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 - 1][j - 1] * j % mod * 4 % mod;
dp[i][j] %= mod;
if (i - 2 >= 0) {
dp[i][j] += dp[i - 2][j - 1] * (i - 1) % mod * j % mod;
dp[i][j] %= mod;
}
if (j - 2 >= 0) {
dp[i][j] += dp[i - 1][j - 2] * (j * (j - 1) / 2 % mod) % mod;
dp[i][j] %= mod;
}
dp[i][j] += dp[i - 1][j];
dp[i][j] %= mod;
}
}
dp[n][m] -= 1;
dp[n][m] += mod;
dp[n][m] %= mod;
cout << dp[n][m] << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
412 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
412 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
1116 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
98 ms |
44184 KB |
Output is correct |
16 |
Correct |
7 ms |
3164 KB |
Output is correct |
17 |
Correct |
22 ms |
10180 KB |
Output is correct |
18 |
Correct |
27 ms |
12636 KB |
Output is correct |
19 |
Correct |
117 ms |
51548 KB |
Output is correct |
20 |
Correct |
91 ms |
41324 KB |
Output is correct |
21 |
Correct |
61 ms |
27228 KB |
Output is correct |
22 |
Correct |
60 ms |
27008 KB |
Output is correct |
23 |
Correct |
33 ms |
15196 KB |
Output is correct |
24 |
Correct |
158 ms |
71052 KB |
Output is correct |
25 |
Correct |
116 ms |
52796 KB |
Output is correct |
26 |
Correct |
134 ms |
60500 KB |
Output is correct |
27 |
Correct |
161 ms |
68180 KB |
Output is correct |