# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
44482 |
2018-04-02T10:22:43 Z |
aome |
Tents (JOI18_tents) |
C++17 |
|
200 ms |
35968 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
const int mod = 1e9 + 7;
int n, m, f[N][N];
void add(int &x, int y) {
x += x + y >= mod ? y - mod : y;
}
int main() {
cin >> n >> m;
f[n][m] = 1;
for (int i = n; i >= 0; --i) {
for (int j = m; j >= 0; --j) {
if (j) {
add(f[i][j - 1], f[i][j]);
if (i) add(f[i - 1][j - 1], 4LL * f[i][j] * i % mod);
if (i > 1) {
add(f[i - 2][j - 1], 1LL * f[i][j] * i * (i - 1) / 2 % mod);
}
if (i && j > 1) {
add(f[i - 1][j - 2], 1LL * f[i][j] * i * (j - 1) % mod);
}
}
else if (i) add(f[i - 1][j], f[i][j]);
}
}
cout << (f[0][0] + mod - 1) % mod;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
560 KB |
Output is correct |
4 |
Correct |
3 ms |
1216 KB |
Output is correct |
5 |
Correct |
2 ms |
1216 KB |
Output is correct |
6 |
Correct |
3 ms |
1384 KB |
Output is correct |
7 |
Correct |
2 ms |
1384 KB |
Output is correct |
8 |
Correct |
3 ms |
1508 KB |
Output is correct |
9 |
Correct |
2 ms |
1508 KB |
Output is correct |
10 |
Correct |
4 ms |
1840 KB |
Output is correct |
11 |
Correct |
2 ms |
1840 KB |
Output is correct |
12 |
Correct |
5 ms |
2096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
560 KB |
Output is correct |
4 |
Correct |
3 ms |
1216 KB |
Output is correct |
5 |
Correct |
2 ms |
1216 KB |
Output is correct |
6 |
Correct |
3 ms |
1384 KB |
Output is correct |
7 |
Correct |
2 ms |
1384 KB |
Output is correct |
8 |
Correct |
3 ms |
1508 KB |
Output is correct |
9 |
Correct |
2 ms |
1508 KB |
Output is correct |
10 |
Correct |
4 ms |
1840 KB |
Output is correct |
11 |
Correct |
2 ms |
1840 KB |
Output is correct |
12 |
Correct |
5 ms |
2096 KB |
Output is correct |
13 |
Correct |
3 ms |
2096 KB |
Output is correct |
14 |
Correct |
11 ms |
9900 KB |
Output is correct |
15 |
Correct |
103 ms |
33048 KB |
Output is correct |
16 |
Correct |
9 ms |
33048 KB |
Output is correct |
17 |
Correct |
29 ms |
33048 KB |
Output is correct |
18 |
Correct |
33 ms |
33048 KB |
Output is correct |
19 |
Correct |
113 ms |
34920 KB |
Output is correct |
20 |
Correct |
92 ms |
34920 KB |
Output is correct |
21 |
Correct |
64 ms |
34920 KB |
Output is correct |
22 |
Correct |
66 ms |
34920 KB |
Output is correct |
23 |
Correct |
45 ms |
34920 KB |
Output is correct |
24 |
Correct |
159 ms |
35968 KB |
Output is correct |
25 |
Correct |
121 ms |
35968 KB |
Output is correct |
26 |
Correct |
190 ms |
35968 KB |
Output is correct |
27 |
Correct |
200 ms |
35968 KB |
Output is correct |