# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
310697 | arnold518 | Tents (JOI18_tents) | C++14 | 1 ms | 384 KiB |
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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 3000;
const ll MOD = 1e9+7;
int N, M;
ll dp[MAXN+10][MAXN+10];
int main()
{
scanf("%d%d", &N, &M);
for(int i=0; i<=N; i++)
{
for(int j=0; j<=M; j++)
{
if(i==0 || j==0)
{
dp[i][j]=1;
continue;
}
if(j>=2) dp[i][j]+=(ll)j*(j-1)/2*dp[i-1][j-2]%MOD;
dp[i][j]+=(ll)4*j*dp[i-1][j-1]%MOD;
if(i>=2) dp[i][j]+=(ll)j*(i-1)*dp[i-2][j-1]%MOD;
dp[i][j]+=dp[i-1][j];
dp[i][j]%=MOD;
}
}
printf("%lld\n", (dp[N][M]+1)%MOD);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |