Submission #131094

# Submission time Handle Problem Language Result Execution time Memory
131094 2019-07-16T12:55:15 Z maruii Tents (JOI18_tents) C++14
100 / 100
157 ms 21644 KB
#include <bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 7;
int A[3001][3001];

int f(int n, int m) {
	if (n < 0 || m < 0) return 0;
	if (!n || !m) return 1;
	if (n > m) swap(n, m);
	if (A[n][m]) return A[n][m];
	return A[n][m] = (f(n, m - 1) + n * (n - 1) / 2ll * f(n - 2, m - 1) + 4ll * n * f(n - 1, m - 1) + 1ll * n * (m - 1) * f(n - 1, m - 2)) % mod;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int H, W; cin >> H >> W;
	cout << f(H, W) - 1;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 632 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 3 ms 760 KB Output is correct
8 Correct 3 ms 632 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 4 ms 1016 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 4 ms 1656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 632 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 3 ms 760 KB Output is correct
8 Correct 3 ms 632 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 4 ms 1016 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 4 ms 1656 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 148 ms 18632 KB Output is correct
16 Correct 15 ms 2560 KB Output is correct
17 Correct 47 ms 6784 KB Output is correct
18 Correct 33 ms 7288 KB Output is correct
19 Correct 157 ms 20504 KB Output is correct
20 Correct 105 ms 16324 KB Output is correct
21 Correct 76 ms 12612 KB Output is correct
22 Correct 83 ms 12960 KB Output is correct
23 Correct 69 ms 7928 KB Output is correct
24 Correct 157 ms 21644 KB Output is correct
25 Correct 109 ms 17656 KB Output is correct
26 Correct 136 ms 19988 KB Output is correct
27 Correct 149 ms 21368 KB Output is correct