Submission #116176

# Submission time Handle Problem Language Result Execution time Memory
116176 2019-06-11T05:09:46 Z dolphingarlic Tents (JOI18_tents) C++14
100 / 100
160 ms 70776 KB
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

ll dp[3001][3001];

int main() {
	int h, w;
	cin >> h >> w;
	dp[0][0] = 1;
	FOR(i, 0, h + 1) {
		FOR(j, 0, w + 1) {
			if(i == 0 || j == 0) dp[i][j] = 1;
			else {
				dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
				dp[i][j] = (dp[i][j] + 4ll * j * dp[i - 1][j - 1]) % MOD;
				if(j > 1) dp[i][j] = (dp[i][j] + 1ll * (1ll * j * (j - 1) / 2) * dp[i - 1][j - 2]) % MOD;
	            if(i > 1) dp[i][j] = (dp[i][j] + 1ll * j * (i - 1) * dp[i - 2][j - 1]) % MOD;
			}
		}
	}
	cout << dp[h][w] - 1 << '\n';
 	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 3 ms 1152 KB Output is correct
5 Correct 2 ms 768 KB Output is correct
6 Correct 3 ms 1408 KB Output is correct
7 Correct 2 ms 896 KB Output is correct
8 Correct 3 ms 1536 KB Output is correct
9 Correct 2 ms 896 KB Output is correct
10 Correct 4 ms 1792 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 4 ms 2304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 3 ms 1152 KB Output is correct
5 Correct 2 ms 768 KB Output is correct
6 Correct 3 ms 1408 KB Output is correct
7 Correct 2 ms 896 KB Output is correct
8 Correct 3 ms 1536 KB Output is correct
9 Correct 2 ms 896 KB Output is correct
10 Correct 4 ms 1792 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 4 ms 2304 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 8 ms 9728 KB Output is correct
15 Correct 123 ms 55232 KB Output is correct
16 Correct 9 ms 4096 KB Output is correct
17 Correct 27 ms 12800 KB Output is correct
18 Correct 33 ms 17144 KB Output is correct
19 Correct 125 ms 62980 KB Output is correct
20 Correct 102 ms 50916 KB Output is correct
21 Correct 66 ms 33784 KB Output is correct
22 Correct 71 ms 35448 KB Output is correct
23 Correct 46 ms 27100 KB Output is correct
24 Correct 160 ms 70776 KB Output is correct
25 Correct 124 ms 61120 KB Output is correct
26 Correct 140 ms 66576 KB Output is correct
27 Correct 152 ms 68984 KB Output is correct