답안 #86966

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
86966 2018-11-29T02:22:07 Z Dat160601 Tents (JOI18_tents) C++17
100 / 100
143 ms 71304 KB
#include <bits/stdc++.h>
using namespace std;

int n, m;
long long dp[3007][3007];
const long long mod = 1e9 + 7;

int main(){
	ios_base::sync_with_stdio(0);
	cin >> n >> m;
	for(int i = 0; i <= m; i++) dp[0][i] = 1;
	for(int i = 0; i <= n; i++) dp[i][0] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			dp[i][j] = (dp[i - 1][j] + 4LL * j * dp[i - 1][j - 1]) % mod;
			if(i >= 2) dp[i][j] = (dp[i][j] + 1LL * (i - 1) * j * dp[i - 2][j - 1]) % mod;
			if(j >= 2) dp[i][j] = (dp[i][j] + 1LL * j * (j - 1) / 2LL * dp[i - 1][j - 2]) % mod;
		}
	}
	dp[n][m] = (dp[n][m] - 1 + mod) % mod;
	cout << dp[n][m];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 292 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 672 KB Output is correct
4 Correct 3 ms 1392 KB Output is correct
5 Correct 3 ms 1392 KB Output is correct
6 Correct 4 ms 1564 KB Output is correct
7 Correct 4 ms 1564 KB Output is correct
8 Correct 3 ms 1740 KB Output is correct
9 Correct 3 ms 1740 KB Output is correct
10 Correct 4 ms 2136 KB Output is correct
11 Correct 2 ms 2136 KB Output is correct
12 Correct 5 ms 2544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 292 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 672 KB Output is correct
4 Correct 3 ms 1392 KB Output is correct
5 Correct 3 ms 1392 KB Output is correct
6 Correct 4 ms 1564 KB Output is correct
7 Correct 4 ms 1564 KB Output is correct
8 Correct 3 ms 1740 KB Output is correct
9 Correct 3 ms 1740 KB Output is correct
10 Correct 4 ms 2136 KB Output is correct
11 Correct 2 ms 2136 KB Output is correct
12 Correct 5 ms 2544 KB Output is correct
13 Correct 2 ms 2544 KB Output is correct
14 Correct 9 ms 10104 KB Output is correct
15 Correct 103 ms 55544 KB Output is correct
16 Correct 8 ms 55544 KB Output is correct
17 Correct 24 ms 55544 KB Output is correct
18 Correct 30 ms 55544 KB Output is correct
19 Correct 110 ms 63300 KB Output is correct
20 Correct 93 ms 63300 KB Output is correct
21 Correct 59 ms 63300 KB Output is correct
22 Correct 60 ms 63300 KB Output is correct
23 Correct 39 ms 63300 KB Output is correct
24 Correct 143 ms 71304 KB Output is correct
25 Correct 130 ms 71304 KB Output is correct
26 Correct 133 ms 71304 KB Output is correct
27 Correct 140 ms 71304 KB Output is correct