# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
667181 |
2022-11-30T16:10:36 Z |
Kahou |
Tents (JOI18_tents) |
C++14 |
|
225 ms |
71204 KB |
#include<bits/stdc++.h>
using namespace std;
#define F first
#define s second
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
const int mod = 1e9 + 7;
int add(int a, int b) {
a += b;
if (a >= mod) a -= mod;
if (a < 0) a += mod;
return a;
}
int mul(int a, int b) {
return 1ll*a*b%mod;
}
const int N = 3005;
int H, W, dp[N][N], dp2[N], C[N][N];
void solve() {
cin >> H >> W;
C[0][0] = 1;
for (int x = 1; x < N; x++) {
C[x][0] = 1;
for (int y = 1; y < N; y++) {
C[x][y] = add(C[x-1][y-1], C[x-1][y]);
}
}
for (int y = 0; y < N; y++) {
dp[0][y] = 1;
}
for (int x = 1; x < N; x++) {
dp[x][0] = 1;
for (int y = 1; y < N; y++) {
dp[x][y] = add(mul(4, mul(dp[x-1][y-1], y)), dp[x-1][y]);
}
}
dp2[0] = 1;
for (int x = 1; x < N/2; x++) {
dp2[x] = mul(dp2[x-1], C[2*x][2]);
}
int ans = 0;
for (int x = 0; x <= H; x++) {
for (int y = 0; y <= W; y++) {
if (x+2*y > H || 2*x+y > W) continue;
int tmp = 1;
tmp = mul(tmp, C[H][x]);
tmp = mul(tmp, C[W][2*x]);
tmp = mul(tmp, C[H-x][2*y]);
tmp = mul(tmp, C[W-2*x][y]);
tmp = mul(tmp, dp[H-x-2*y][W-2*x-y]);
tmp = mul(tmp, dp2[x]);
tmp = mul(tmp, dp2[y]);
ans = add(ans, tmp);
}
}
cout << ans-1 << endl;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
146 ms |
70920 KB |
Output is correct |
2 |
Correct |
147 ms |
70920 KB |
Output is correct |
3 |
Correct |
150 ms |
70888 KB |
Output is correct |
4 |
Correct |
149 ms |
70976 KB |
Output is correct |
5 |
Correct |
147 ms |
71204 KB |
Output is correct |
6 |
Correct |
157 ms |
70972 KB |
Output is correct |
7 |
Correct |
147 ms |
70992 KB |
Output is correct |
8 |
Correct |
146 ms |
70988 KB |
Output is correct |
9 |
Correct |
145 ms |
70916 KB |
Output is correct |
10 |
Correct |
145 ms |
70896 KB |
Output is correct |
11 |
Correct |
155 ms |
70876 KB |
Output is correct |
12 |
Correct |
154 ms |
71052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
146 ms |
70920 KB |
Output is correct |
2 |
Correct |
147 ms |
70920 KB |
Output is correct |
3 |
Correct |
150 ms |
70888 KB |
Output is correct |
4 |
Correct |
149 ms |
70976 KB |
Output is correct |
5 |
Correct |
147 ms |
71204 KB |
Output is correct |
6 |
Correct |
157 ms |
70972 KB |
Output is correct |
7 |
Correct |
147 ms |
70992 KB |
Output is correct |
8 |
Correct |
146 ms |
70988 KB |
Output is correct |
9 |
Correct |
145 ms |
70916 KB |
Output is correct |
10 |
Correct |
145 ms |
70896 KB |
Output is correct |
11 |
Correct |
155 ms |
70876 KB |
Output is correct |
12 |
Correct |
154 ms |
71052 KB |
Output is correct |
13 |
Correct |
152 ms |
70920 KB |
Output is correct |
14 |
Correct |
151 ms |
70920 KB |
Output is correct |
15 |
Correct |
199 ms |
70988 KB |
Output is correct |
16 |
Correct |
150 ms |
70884 KB |
Output is correct |
17 |
Correct |
152 ms |
70964 KB |
Output is correct |
18 |
Correct |
154 ms |
70904 KB |
Output is correct |
19 |
Correct |
201 ms |
71088 KB |
Output is correct |
20 |
Correct |
203 ms |
70996 KB |
Output is correct |
21 |
Correct |
169 ms |
71020 KB |
Output is correct |
22 |
Correct |
168 ms |
71052 KB |
Output is correct |
23 |
Correct |
153 ms |
70904 KB |
Output is correct |
24 |
Correct |
225 ms |
70956 KB |
Output is correct |
25 |
Correct |
197 ms |
70928 KB |
Output is correct |
26 |
Correct |
210 ms |
71000 KB |
Output is correct |
27 |
Correct |
212 ms |
70916 KB |
Output is correct |