이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// trans rights
#include <bits/extc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int mod = 1000000007;
int W, H;
int cache[3069][3069];
bool done[3069][3069];
int dp(int i, int j)
{
if (i <= 0 or j <= 0)
return 1;
bool &d = done[i][j];
int &ans = cache[i][j];
if (d)
return ans;
ans = (4ll * j * dp(i - 1, j - 1) + dp(i - 1, j)) % mod;
ll B = ((ll) j * (j - 1)) / 2;
if (i >= 2)
ans = (ans + (ll) (i - 1) * j * dp(i - 2, j - 1)) % mod;
if (j >= 2)
ans = (ans + B * dp(i - 1, j - 2)) % mod;
d = true;
return ans;
}
int main(int argc, const char *argv[])
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> W >> H;
cout << (dp(W, H) - 1 + mod) % mod;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |