This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
using namespace std;
long long int f[3005][3005], mod = 1e9 + 7;
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= m; j++) {
if (i == 0 || j == 0) f[i][j] = 1;
else {
f[i][j] = f[i - 1][j];
f[i][j] += f[i - 1][j - 1] * j * 4;
if (j >= 2) f[i][j] += f[i - 1][j - 2] * (j * (j - 1) / 2) % mod;
if (i >= 2) f[i][j] += f[i - 2][j - 1] * (i - 1) * j;
f[i][j] %= mod;
}
}
}
cout << (f[n][m] + mod - 1) % mod;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |