Submission #237394

# Submission time Handle Problem Language Result Execution time Memory
237394 2020-06-06T12:20:51 Z clairvoyant Tents (JOI18_tents) C++14
100 / 100
386 ms 59000 KB
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define all int i=0; i<n; i++
#define INF LLONG_MAX
#define Nirvana ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define mod 1000000007
#define ll long long int
#define int ll
#define T int t;cin>>t;while(t--)

int dp[3001][3001];

int rec(int i, int j){
	if(i<0 || j<0)return 0;
	if(i==0 || j==0)return 1;
	
	if(dp[i][j])return dp[i][j];
	
	dp[i][j] += (4*j*rec(i-1, j-1))%mod;
	dp[i][j]%=mod;
	dp[i][j] += (rec(i-1, j));
	dp[i][j]%=mod;
	dp[i][j] += (((j*(j-1))/2) * (rec(i-1, j-2)))%mod;
	dp[i][j]%=mod;
	dp[i][j] += (j*(i-1) * rec(i-2, j-1));
	dp[i][j]%=mod;
	
	return dp[i][j];
}
signed main(){
	Nirvana;
	int n,m;
	cin>>n>>m;
	
	cout<<(rec(n, m)-1 + mod)%mod<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 1152 KB Output is correct
5 Correct 5 ms 640 KB Output is correct
6 Correct 6 ms 1408 KB Output is correct
7 Correct 5 ms 768 KB Output is correct
8 Correct 6 ms 1408 KB Output is correct
9 Correct 5 ms 896 KB Output is correct
10 Correct 7 ms 1792 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 8 ms 2048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 1152 KB Output is correct
5 Correct 5 ms 640 KB Output is correct
6 Correct 6 ms 1408 KB Output is correct
7 Correct 5 ms 768 KB Output is correct
8 Correct 6 ms 1408 KB Output is correct
9 Correct 5 ms 896 KB Output is correct
10 Correct 7 ms 1792 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 8 ms 2048 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 11 ms 9856 KB Output is correct
15 Correct 267 ms 47480 KB Output is correct
16 Correct 7 ms 1664 KB Output is correct
17 Correct 27 ms 6912 KB Output is correct
18 Correct 59 ms 13688 KB Output is correct
19 Correct 302 ms 53508 KB Output is correct
20 Correct 250 ms 42232 KB Output is correct
21 Correct 129 ms 25592 KB Output is correct
22 Correct 147 ms 30844 KB Output is correct
23 Correct 115 ms 26488 KB Output is correct
24 Correct 386 ms 59000 KB Output is correct
25 Correct 305 ms 49272 KB Output is correct
26 Correct 335 ms 54776 KB Output is correct
27 Correct 379 ms 57020 KB Output is correct