이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
int main()
{
cin.tie(nullptr)->sync_with_stdio(0);
int h, w;
cin >> h >> w;
vector<vector<long long>> dp(h + 1, vector<long long>(w + 1));
auto C2 = [](int x) {
return x * (x - 1) / 2;
};
for(int i = 0; i <= h; i++) {
for(int j = 0; j <= w; j++) {
if(i == 0 || j == 0) {
dp[i][j] = 1;
continue;
}
dp[i][j] += dp[i][j - 1];
dp[i][j] += 4ll * i * dp[i - 1][j - 1];
if(i >= 2) {
dp[i][j] += C2(i) * dp[i - 2][j - 1];
}
if(j >= 2) {
dp[i][j] += i * (j - 1) * dp[i - 1][j - 2];
}
dp[i][j] %= mod;
}
}
cout << (dp[h][w] - 1 + mod) % mod << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |