답안 #610089

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
610089 2022-07-28T04:53:40 Z penguinhacker Tents (JOI18_tents) C++17
100 / 100
117 ms 70764 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ar array

const int mxN=3000, M=1e9+7;
int n, m;
ll dp[mxN+1][mxN+1];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for (int i=0; i<=max(n, m); ++i)
		dp[0][i]=dp[i][0]=1;
	for (int i=1; i<=n; ++i)
		for (int j=1; j<=m; ++j) {
			// two tents on row 1
			dp[i][j]=dp[i-1][j];
			if (j>=2)
				dp[i][j]=(dp[i][j]+dp[i-1][j-2]*j*(j-1)/2)%M;
			dp[i][j]=(dp[i][j]+dp[i-1][j-1]*4*j)%M;
			if (i>=2)
				dp[i][j]=(dp[i][j]+dp[i-2][j-1]*j*(i-1))%M;
		}
	cout << (dp[n][m]-1+M)%M;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 1096 KB Output is correct
5 Correct 1 ms 1356 KB Output is correct
6 Correct 1 ms 1364 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1364 KB Output is correct
9 Correct 1 ms 724 KB Output is correct
10 Correct 2 ms 1748 KB Output is correct
11 Correct 1 ms 1492 KB Output is correct
12 Correct 3 ms 2132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 1096 KB Output is correct
5 Correct 1 ms 1356 KB Output is correct
6 Correct 1 ms 1364 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1364 KB Output is correct
9 Correct 1 ms 724 KB Output is correct
10 Correct 2 ms 1748 KB Output is correct
11 Correct 1 ms 1492 KB Output is correct
12 Correct 3 ms 2132 KB Output is correct
13 Correct 3 ms 7756 KB Output is correct
14 Correct 4 ms 9684 KB Output is correct
15 Correct 67 ms 55112 KB Output is correct
16 Correct 8 ms 9428 KB Output is correct
17 Correct 21 ms 17284 KB Output is correct
18 Correct 22 ms 17736 KB Output is correct
19 Correct 69 ms 62944 KB Output is correct
20 Correct 55 ms 50800 KB Output is correct
21 Correct 41 ms 35408 KB Output is correct
22 Correct 37 ms 35480 KB Output is correct
23 Correct 26 ms 26968 KB Output is correct
24 Correct 117 ms 70764 KB Output is correct
25 Correct 78 ms 61132 KB Output is correct
26 Correct 78 ms 66496 KB Output is correct
27 Correct 85 ms 69052 KB Output is correct