Submission #237966

# Submission time Handle Problem Language Result Execution time Memory
237966 2020-06-09T14:14:47 Z sahil_k Tents (JOI18_tents) C++14
100 / 100
117 ms 70780 KB
#include <iostream>
#define MOD 1000000007
using namespace std;
long long dp[3001][3001];
int main () {
	int n, m;
	cin >> n >> m;
	for (int i=0; i<=n; i++) {
		for (int j=0; j<=m; j++) {
			if (i == 0 || j == 0) {
				dp[i][j] = 1;
				continue;
			}
			dp[i][j] = dp[i-1][j];
			dp[i][j] = (dp[i][j]+4ll*dp[i-1][j-1]*j)%MOD;
			dp[i][j] = (dp[i][j]+1ll*dp[i-1][max(0, j-2)]*j*(j-1)/2)%MOD;
			dp[i][j] = (dp[i][j]+1ll*dp[max(0, i-2)][j-1]*j*(i-1))%MOD;
		}
	}
	cout << dp[n][m]-1 << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 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 768 KB Output is correct
6 Correct 6 ms 1408 KB Output is correct
7 Correct 5 ms 896 KB Output is correct
8 Correct 6 ms 1408 KB Output is correct
9 Correct 5 ms 768 KB Output is correct
10 Correct 5 ms 1792 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 6 ms 2304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 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 768 KB Output is correct
6 Correct 6 ms 1408 KB Output is correct
7 Correct 5 ms 896 KB Output is correct
8 Correct 6 ms 1408 KB Output is correct
9 Correct 5 ms 768 KB Output is correct
10 Correct 5 ms 1792 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 6 ms 2304 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 9 ms 9728 KB Output is correct
15 Correct 85 ms 55136 KB Output is correct
16 Correct 12 ms 4096 KB Output is correct
17 Correct 22 ms 12928 KB Output is correct
18 Correct 27 ms 17144 KB Output is correct
19 Correct 116 ms 62968 KB Output is correct
20 Correct 74 ms 50936 KB Output is correct
21 Correct 54 ms 33784 KB Output is correct
22 Correct 50 ms 35448 KB Output is correct
23 Correct 37 ms 27128 KB Output is correct
24 Correct 117 ms 70780 KB Output is correct
25 Correct 96 ms 61172 KB Output is correct
26 Correct 106 ms 66552 KB Output is correct
27 Correct 117 ms 68984 KB Output is correct