Submission #781372

# Submission time Handle Problem Language Result Execution time Memory
781372 2023-07-13T04:50:56 Z 박영우(#10014) Tents (JOI18_tents) C++17
100 / 100
42 ms 71012 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 3010
#define MAXS 22
#define INF 1000000000000000001
#define bb ' '
#define ln '\n'
#define Ln '\n'
#define MOD 1000000007
ll dp[MAX][MAX];
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int H, W;
	cin >> H >> W;
	int i, j;
	for (i = 1; i <= W; i++) dp[1][i] = 1ll + 4ll * i + (i - 1ll) * i / 2;
	for (i = 0; i <= max(H, W); i++) dp[0][i] = dp[i][0] = 1;
	for (i = 2; i <= H; i++) {
		dp[i][1] = 1ll + 4ll * i + (i - 1ll) * i / 2;
		dp[i][1] %= MOD;
		for (j = 2; j <= W; j++) {
			dp[i][j] = dp[i - 1][j] + 4ll * j * dp[i - 1][j - 1] + (1ll * j * (j - 1ll) / 2ll) * dp[i - 1][j - 2] + (i - 1ll) * j * dp[i - 2][j - 1];
			dp[i][j] %= MOD;
		}
	}
	cout << (dp[H][W] + MOD - 1) % MOD;
}
# Verdict Execution time Memory 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 1108 KB Output is correct
5 Correct 1 ms 1364 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 1 ms 1748 KB Output is correct
11 Correct 1 ms 1492 KB Output is correct
12 Correct 2 ms 2120 KB Output is correct
# Verdict Execution time Memory 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 1108 KB Output is correct
5 Correct 1 ms 1364 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 1 ms 1748 KB Output is correct
11 Correct 1 ms 1492 KB Output is correct
12 Correct 2 ms 2120 KB Output is correct
13 Correct 3 ms 7756 KB Output is correct
14 Correct 4 ms 9700 KB Output is correct
15 Correct 29 ms 55168 KB Output is correct
16 Correct 5 ms 9428 KB Output is correct
17 Correct 9 ms 17364 KB Output is correct
18 Correct 10 ms 17840 KB Output is correct
19 Correct 34 ms 62968 KB Output is correct
20 Correct 28 ms 50892 KB Output is correct
21 Correct 20 ms 35448 KB Output is correct
22 Correct 20 ms 35392 KB Output is correct
23 Correct 17 ms 27216 KB Output is correct
24 Correct 42 ms 71012 KB Output is correct
25 Correct 34 ms 61292 KB Output is correct
26 Correct 38 ms 66680 KB Output is correct
27 Correct 42 ms 69280 KB Output is correct