답안 #237392

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
237392 2020-06-06T12:19:30 Z clairvoyant Tents (JOI18_tents) C++14
48 / 100
301 ms 53500 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[3000][3000];

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;
}



# 결과 실행 시간 메모리 Grader output
1 Correct 5 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 1536 KB Output is correct
9 Correct 5 ms 896 KB Output is correct
10 Correct 6 ms 1792 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 10 ms 2048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 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 1536 KB Output is correct
9 Correct 5 ms 896 KB Output is correct
10 Correct 6 ms 1792 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 10 ms 2048 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 11 ms 9856 KB Output is correct
15 Correct 260 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 63 ms 13712 KB Output is correct
19 Correct 301 ms 53500 KB Output is correct
20 Correct 227 ms 42360 KB Output is correct
21 Correct 135 ms 25720 KB Output is correct
22 Correct 149 ms 30816 KB Output is correct
23 Correct 117 ms 26616 KB Output is correct
24 Runtime error 8 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Halted 0 ms 0 KB -