# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
56310 | 2018-07-11T04:27:19 Z | 김세빈(#1599) | Tents (JOI18_tents) | C++11 | 441 ms | 189348 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1e9 + 7; ll H[3030][3030], V[3030][3030]; ll D[3030][3030]; ll n, m, ans; int main() { ll i, j; scanf("%lld%lld", &n, &m); H[0][0] = V[0][0] = 1; D[0][0] = 1; for(i=1;i<=n || i<=m;i++){ D[i][0] = 1; for(j=1;j<=i;j++){ D[i][j] = (D[i-1][j-1] + D[i-1][j]) % mod; } } for(i=1;i<=n;i++){ for(j=0;j<=m;j++){ V[i][j] = V[i-1][j]; if(j >= 1) V[i][j] = (V[i][j] + V[i-1][j-1] * j * 2) % mod; if(j >= 2) V[i][j] = (V[i][j] + V[i-1][j-2] * (j * (j-1) / 2)) % mod; } } for(i=0;i<=n;i++){ for(j=1;j<=m;j++){ H[i][j] = H[i][j-1]; if(i >= 1) H[i][j] = (H[i][j] + H[i-1][j-1] * i * 2) % mod; if(i >= 2) H[i][j] = (H[i][j] + H[i-2][j-1] * (i * (i-1) / 2)) % mod; } } for(i=0;i<=n;i++){ for(j=0;j<=m;j++){ ans = (ans + V[i][j] * H[n-i][m-j] % mod * D[n][i] % mod * D[m][j] % mod) % mod; } } printf("%lld\n", (ans - 1 + mod) % mod); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 1252 KB | Output is correct |
3 | Correct | 2 ms | 1252 KB | Output is correct |
4 | Correct | 5 ms | 3196 KB | Output is correct |
5 | Correct | 5 ms | 3196 KB | Output is correct |
6 | Correct | 8 ms | 3824 KB | Output is correct |
7 | Correct | 5 ms | 3824 KB | Output is correct |
8 | Correct | 6 ms | 4160 KB | Output is correct |
9 | Correct | 4 ms | 4160 KB | Output is correct |
10 | Correct | 8 ms | 5040 KB | Output is correct |
11 | Correct | 4 ms | 5040 KB | Output is correct |
12 | Correct | 11 ms | 5984 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 1252 KB | Output is correct |
3 | Correct | 2 ms | 1252 KB | Output is correct |
4 | Correct | 5 ms | 3196 KB | Output is correct |
5 | Correct | 5 ms | 3196 KB | Output is correct |
6 | Correct | 8 ms | 3824 KB | Output is correct |
7 | Correct | 5 ms | 3824 KB | Output is correct |
8 | Correct | 6 ms | 4160 KB | Output is correct |
9 | Correct | 4 ms | 4160 KB | Output is correct |
10 | Correct | 8 ms | 5040 KB | Output is correct |
11 | Correct | 4 ms | 5040 KB | Output is correct |
12 | Correct | 11 ms | 5984 KB | Output is correct |
13 | Correct | 22 ms | 21216 KB | Output is correct |
14 | Correct | 50 ms | 49504 KB | Output is correct |
15 | Correct | 300 ms | 151116 KB | Output is correct |
16 | Correct | 34 ms | 151116 KB | Output is correct |
17 | Correct | 82 ms | 151116 KB | Output is correct |
18 | Correct | 91 ms | 151116 KB | Output is correct |
19 | Correct | 351 ms | 170152 KB | Output is correct |
20 | Correct | 249 ms | 170152 KB | Output is correct |
21 | Correct | 189 ms | 170152 KB | Output is correct |
22 | Correct | 176 ms | 170152 KB | Output is correct |
23 | Correct | 139 ms | 170152 KB | Output is correct |
24 | Correct | 441 ms | 189348 KB | Output is correct |
25 | Correct | 340 ms | 189348 KB | Output is correct |
26 | Correct | 407 ms | 189348 KB | Output is correct |
27 | Correct | 417 ms | 189348 KB | Output is correct |