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 <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 4, MOD = 1e9 + 7;
int n, m, _dp[N][N];
int dp(int i, int j) {
if (i < 0 || j < 0)
return 0;
else if (!i || !j)
return 1;
else
return _dp[i][j];
}
int c(int k) {
return k * (k - 1) / 2;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
for (int i = 1; i < N; ++i) {
for (int j = 1; j < N; ++j) {
_dp[i][j] = dp(i, j - 1);
_dp[i][j] = (_dp[i][j] + 4ll * i * dp(i - 1, j - 1) % MOD) % MOD;
_dp[i][j] = (_dp[i][j] + 1ll * c(i) * dp(i - 2, j - 1) % MOD) % MOD;
_dp[i][j] = (_dp[i][j] + 1ll * i * (j - 1) * dp(i - 1, j - 2) % MOD) % MOD;
}
}
cin >> n >> m;
cout << (dp(n, m) + MOD - 1) % MOD;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |