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>
#include <cassert>
#include <cstring>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <utility>
#include <array>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,tune=native")
using namespace std;
#define ALL(x) x.begin(), x.end()
#define ShinLena cin.tie(nullptr)->sync_with_stdio(false);
using ll = long long;
#define N 3050
const ll M = 1000000007;
int h, w;
int dp[N][N];
int main()
{
ShinLena;
cin >> h >> w;
for (int i = 0; i < N; ++i) dp[0][i] = dp[i][0] = 1;
for (int i = 1; i <= h; ++i) for (int j = 1; j <= w; ++j)
{
(dp[i][j] += dp[i-1][j] + (4ll * j * dp[i-1][j-1] % M)) %= M;
if (i > 1) (dp[i][j] += (1ll*(i-1)*j%M) * dp[i-2][j-1] % M) %= M;
if (j > 1) (dp[i][j] += (1ll*j*(j-1)%M*500000004%M) * dp[i-1][j-2] % M) %= M;
}
cout << (dp[h][w] + M - 1) % M << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |