# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
523413 |
2022-02-07T15:34:25 Z |
CPSC |
Tents (JOI18_tents) |
C++14 |
|
134 ms |
70836 KB |
# include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define int long long
using namespace std;
const int N = 3005, mod = 1e9 + 7;
int n,m,dp[N][N];
int C(int n, int k) {
return (n*(n - 1)) / 2;
}
main() {
cin>>n>>m;
for (int i = 0; i <= max(n,m); i++) dp[0][i] = dp[i][0] = 1;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
dp[i][j] += dp[i - 1][j];
if (j >= 2)
dp[i][j] += dp[i - 1][j - 2] * C(j,2);
dp[i][j] %= mod;
dp[i][j] += dp[i - 1][j - 1] * 4*j;dp[i][j] %= mod;
if (i >= 2)
dp[i][j] += dp[i - 2][j - 1] * j * (i - 1);
dp[i][j] %= mod;
}
}
dp[n][m] --;
if (dp[n][m] < 0) dp[n][m] += mod;
cout<<dp[n][m]<<endl;
}
Compilation message
tents.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
12 | main() {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
920 KB |
Output is correct |
3 |
Correct |
1 ms |
460 KB |
Output is correct |
4 |
Correct |
1 ms |
1100 KB |
Output is correct |
5 |
Correct |
2 ms |
1456 KB |
Output is correct |
6 |
Correct |
1 ms |
1356 KB |
Output is correct |
7 |
Correct |
1 ms |
1356 KB |
Output is correct |
8 |
Correct |
1 ms |
1356 KB |
Output is correct |
9 |
Correct |
1 ms |
716 KB |
Output is correct |
10 |
Correct |
1 ms |
1740 KB |
Output is correct |
11 |
Correct |
1 ms |
1452 KB |
Output is correct |
12 |
Correct |
2 ms |
2124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
920 KB |
Output is correct |
3 |
Correct |
1 ms |
460 KB |
Output is correct |
4 |
Correct |
1 ms |
1100 KB |
Output is correct |
5 |
Correct |
2 ms |
1456 KB |
Output is correct |
6 |
Correct |
1 ms |
1356 KB |
Output is correct |
7 |
Correct |
1 ms |
1356 KB |
Output is correct |
8 |
Correct |
1 ms |
1356 KB |
Output is correct |
9 |
Correct |
1 ms |
716 KB |
Output is correct |
10 |
Correct |
1 ms |
1740 KB |
Output is correct |
11 |
Correct |
1 ms |
1452 KB |
Output is correct |
12 |
Correct |
2 ms |
2124 KB |
Output is correct |
13 |
Correct |
4 ms |
7712 KB |
Output is correct |
14 |
Correct |
4 ms |
9548 KB |
Output is correct |
15 |
Correct |
72 ms |
55052 KB |
Output is correct |
16 |
Correct |
7 ms |
9292 KB |
Output is correct |
17 |
Correct |
17 ms |
17344 KB |
Output is correct |
18 |
Correct |
20 ms |
17712 KB |
Output is correct |
19 |
Correct |
80 ms |
62900 KB |
Output is correct |
20 |
Correct |
65 ms |
50860 KB |
Output is correct |
21 |
Correct |
46 ms |
35412 KB |
Output is correct |
22 |
Correct |
43 ms |
35372 KB |
Output is correct |
23 |
Correct |
27 ms |
27040 KB |
Output is correct |
24 |
Correct |
104 ms |
70836 KB |
Output is correct |
25 |
Correct |
74 ms |
61124 KB |
Output is correct |
26 |
Correct |
93 ms |
66588 KB |
Output is correct |
27 |
Correct |
134 ms |
69060 KB |
Output is correct |