답안 #94112

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
94112 2019-01-16T06:40:58 Z autumn_eel Tents (JOI18_tents) C++14
100 / 100
139 ms 82248 KB
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

ll dp[4000][4000];
int main(){
	int h,w;cin>>h>>w;
	dp[0][w]=1;
	rep(i,h)rep(j,w+1){
		//0
		(dp[i+1][j]+=dp[i][j])%=MOD;
		//1
		if(j)(dp[i+1][j-1]+=dp[i][j]*j*4)%=MOD;
		//N-S
		if(j&&i<h-1)(dp[i+2][j-1]+=dp[i][j]*j*(h-i-1))%=MOD;
		//E-W
		if(j>=2)(dp[i+1][j-2]+=dp[i][j]*(j*(j-1)/2))%=MOD;
	}
	ll ans=0;
	rep(i,w+1)(ans+=dp[h][i])%=MOD;
	cout<<(ans+MOD-1)%MOD<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 1148 KB Output is correct
5 Correct 2 ms 632 KB Output is correct
6 Correct 2 ms 1400 KB Output is correct
7 Correct 2 ms 888 KB Output is correct
8 Correct 3 ms 1400 KB Output is correct
9 Correct 2 ms 764 KB Output is correct
10 Correct 17 ms 1784 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 4 ms 2168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 1148 KB Output is correct
5 Correct 2 ms 632 KB Output is correct
6 Correct 2 ms 1400 KB Output is correct
7 Correct 2 ms 888 KB Output is correct
8 Correct 3 ms 1400 KB Output is correct
9 Correct 2 ms 764 KB Output is correct
10 Correct 17 ms 1784 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 4 ms 2168 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 10 ms 9640 KB Output is correct
15 Correct 96 ms 55096 KB Output is correct
16 Correct 7 ms 3960 KB Output is correct
17 Correct 24 ms 12764 KB Output is correct
18 Correct 31 ms 16888 KB Output is correct
19 Correct 112 ms 63096 KB Output is correct
20 Correct 88 ms 50652 KB Output is correct
21 Correct 58 ms 33528 KB Output is correct
22 Correct 57 ms 35192 KB Output is correct
23 Correct 40 ms 26744 KB Output is correct
24 Correct 139 ms 82248 KB Output is correct
25 Correct 107 ms 62684 KB Output is correct
26 Correct 118 ms 70904 KB Output is correct
27 Correct 133 ms 79352 KB Output is correct