Submission #751709

# Submission time Handle Problem Language Result Execution time Memory
751709 2023-06-01T10:11:19 Z Dan4Life Tents (JOI18_tents) C++17
100 / 100
71 ms 70972 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mxN = (int)3e3+10;
const int MOD = (int)1e9+7;
int n, m, dp[mxN][mxN];

int32_t main() {
	cin >> n >> m;
	for(int i = 0; i < mxN; i++) dp[i][0]=dp[0][i]=1;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			dp[i][j] += dp[i-1][j]; // empty row
			dp[i][j] += 4*j*dp[i-1][j-1]; // exactly 1 on row
			if(j>1) dp[i][j] += (j-1)*j/2*dp[i-1][j-2]; // exactly 2 on row
			if(i>1) dp[i][j] += j*(i-1) * dp[i-2][j-1]; //1 on both row and col
			dp[i][j]%=MOD;
		}
	}
	cout << (dp[n][m]+MOD-1)%MOD << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 12500 KB Output is correct
2 Correct 6 ms 12440 KB Output is correct
3 Correct 6 ms 12536 KB Output is correct
4 Correct 6 ms 12500 KB Output is correct
5 Correct 5 ms 12628 KB Output is correct
6 Correct 7 ms 12628 KB Output is correct
7 Correct 6 ms 12612 KB Output is correct
8 Correct 5 ms 12500 KB Output is correct
9 Correct 5 ms 12500 KB Output is correct
10 Correct 6 ms 12756 KB Output is correct
11 Correct 6 ms 12500 KB Output is correct
12 Correct 6 ms 13140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 12500 KB Output is correct
2 Correct 6 ms 12440 KB Output is correct
3 Correct 6 ms 12536 KB Output is correct
4 Correct 6 ms 12500 KB Output is correct
5 Correct 5 ms 12628 KB Output is correct
6 Correct 7 ms 12628 KB Output is correct
7 Correct 6 ms 12612 KB Output is correct
8 Correct 5 ms 12500 KB Output is correct
9 Correct 5 ms 12500 KB Output is correct
10 Correct 6 ms 12756 KB Output is correct
11 Correct 6 ms 12500 KB Output is correct
12 Correct 6 ms 13140 KB Output is correct
13 Correct 5 ms 12500 KB Output is correct
14 Correct 5 ms 12500 KB Output is correct
15 Correct 47 ms 56076 KB Output is correct
16 Correct 8 ms 15188 KB Output is correct
17 Correct 16 ms 22204 KB Output is correct
18 Correct 18 ms 24532 KB Output is correct
19 Correct 56 ms 63280 KB Output is correct
20 Correct 42 ms 53068 KB Output is correct
21 Correct 35 ms 39232 KB Output is correct
22 Correct 29 ms 38792 KB Output is correct
23 Correct 20 ms 27128 KB Output is correct
24 Correct 62 ms 70972 KB Output is correct
25 Correct 54 ms 62924 KB Output is correct
26 Correct 60 ms 67432 KB Output is correct
27 Correct 71 ms 69384 KB Output is correct