Submission #258090

# Submission time Handle Problem Language Result Execution time Memory
258090 2020-08-05T10:39:37 Z YJU Tents (JOI18_tents) C++14
100 / 100
159 ms 70904 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll N=3e3+5;
const ll M=1e4+5;
const ll MOD=1e9+7;
const ld pi=acos(-1);
const ll MOD2=998244353;
const ll INF=(1LL<<60);
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lwb lower_bound
#define SZ(a) (ll)a.size()

ll n,m,dp[N][N];

ll C(ll k){
	if(k<2)return 0;
	return (k*(k-1)%MOD)*((MOD+1)/2)%MOD;
}

 
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>m;
	REP(i,n+1)dp[i][0]=1;REP(i,m+1)dp[0][i]=1;
	REP1(i,n){
		REP1(j,m){
			dp[i][j]+=dp[i-1][j];
			dp[i][j]+=dp[i-1][j-1]*j%MOD*4%MOD;
			if(j>=2)dp[i][j]+=dp[i-1][j-2]*(C(j))%MOD;
			if(i>=2)dp[i][j]+=dp[i-2][j-1]*(i-1)%MOD*j%MOD;
			dp[i][j]%=MOD;		
		}
	}
	cout<<(dp[n][m]+MOD-1)%MOD<<"\n";
	return 0;	
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 512 KB Output is correct
4 Correct 1 ms 1152 KB Output is correct
5 Correct 1 ms 768 KB Output is correct
6 Correct 1 ms 1408 KB Output is correct
7 Correct 1 ms 896 KB Output is correct
8 Correct 2 ms 1536 KB Output is correct
9 Correct 1 ms 896 KB Output is correct
10 Correct 2 ms 1792 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 5 ms 2304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 512 KB Output is correct
4 Correct 1 ms 1152 KB Output is correct
5 Correct 1 ms 768 KB Output is correct
6 Correct 1 ms 1408 KB Output is correct
7 Correct 1 ms 896 KB Output is correct
8 Correct 2 ms 1536 KB Output is correct
9 Correct 1 ms 896 KB Output is correct
10 Correct 2 ms 1792 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 5 ms 2304 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 5 ms 9728 KB Output is correct
15 Correct 106 ms 55268 KB Output is correct
16 Correct 7 ms 4096 KB Output is correct
17 Correct 24 ms 12872 KB Output is correct
18 Correct 30 ms 17144 KB Output is correct
19 Correct 125 ms 63084 KB Output is correct
20 Correct 99 ms 50972 KB Output is correct
21 Correct 68 ms 33784 KB Output is correct
22 Correct 67 ms 35448 KB Output is correct
23 Correct 39 ms 27128 KB Output is correct
24 Correct 159 ms 70904 KB Output is correct
25 Correct 136 ms 61304 KB Output is correct
26 Correct 139 ms 66680 KB Output is correct
27 Correct 158 ms 68984 KB Output is correct