이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define N 3030
#define mod (1000000007)
using namespace std;
typedef long long ll;
ll H, W, dp[N][N];
ll solve(int lf, int cf)
{
if(lf < 0 || cf < 0) return 0;
if(!lf || !cf) return 1;
if(dp[lf][cf] != -1) return dp[lf][cf];
ll nao_coloca = solve(lf - 1, cf), coloca1 = solve(lf - 1, cf - 1)*4*cf;
ll coloca2 = solve(lf - 1, cf - 2)*cf*(cf - 1)/2, coloca2row = solve(lf - 2, cf - 1)*cf*(lf - 1);
return dp[lf][cf] = (nao_coloca + coloca1 + coloca2 + coloca2row)%mod;
}
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
cin>>H>>W;
memset(dp, -1, sizeof dp);
cout<<(solve(H, W) + mod - 1)%mod<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |