# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
331391 | GioChkhaidze | Tents (JOI18_tents) | C++14 | 319 ms | 70892 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>
#define ll long long
using namespace std;
const int N=3003;
ll n,m,dp[N][N],mod=1e9+7;
main () {
cin>>n>>m;
for (int i=0; i<=max(n,m); i++)
dp[i][0]=dp[0][i]=1;
for (int i=1; i<=n; i++)
for (int j=1; j<=m; j++) {
if (1<=i) dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
if (1<=i && 1<=j) dp[i][j]=(dp[i][j]+j*dp[i-1][j-1]*4)%mod;
if (2<=i && 1<=j) dp[i][j]=(dp[i][j]+j*(i-1)*dp[i-2][j-1])%mod;
if (1<=i && 2<=j) dp[i][j]=(dp[i][j]+((j-1)*j/2)*dp[i-1][j-2])%mod;
}
cout<<(dp[n][m]-1+mod)%mod<<"\n";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |