#include <iostream>
#define int long long
using namespace std;
const int mod = 1e9 + 7;
long long dp[3005][3005];
signed main()
{
dp[1][1] = 5;
for (int i = 2; i <= 3000; i++) {
dp[i][1] = dp[1][i] = i * (i-1) / 2 + i * 4 + 1;
}
for (int i = 1; i <= 3000; i++) {
dp[i][0] = dp[0][i] = 1;
}
for (int i = 2; i <= 3000; i++) {
for (int j = 2; j <= 3000; j++) {
dp[i][j] = (j * (j-1) / 2 * dp[i-1][j-2] + j * (i-1) * dp[i-2][j-1] + j * 4 * dp[i-1][j-1] + dp[i-1][j]) % mod;
}
}
int h, w; cin >> h >> w;
cout << dp[h][w] - 1 << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
46 ms |
70860 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
108 ms |
143516 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
100 ms |
143540 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
100 ms |
143524 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
46 ms |
70860 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |