# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
127489 |
2019-07-09T12:44:05 Z |
RockyB |
Tents (JOI18_tents) |
C++17 |
|
251 ms |
35576 KB |
#include <bits/stdc++.h>
#define rep(a, b, c) for (int a = (b); (a) <= (c); a++)
#define per(a, b, c) for (int a = (b); (a) >= (c); a--)
#define nl '\n'
#define ioi exit(0);
const int mod = (int)1e9 + 7;
const int N = (int)1e4;
using namespace std;
void add(int &x, int y) {
x += y;
if (x >= mod) x -= mod;
if (x < 0) x += mod;
}
int sum(int x, int y) {
add(x, y);
return x;
}
int n, m;
int dp[3001][3001];
int main() {
#ifdef IOI
freopen ("in.txt", "r", stdin);
freopen ("slow.out", "w", stdout);
#endif
cin >> n >> m;
/* memset(dp, -1, sizeof(dp));
int ans = sum(calc(), -1);
cout << ans << nl; */
dp[0][m] = 1;
rep(i, 0, n - 1) {
rep(j, 0, m) {
// skip
add(dp[i + 1][j], dp[i][j]);
// put any char
if (j > 0) add(dp[i + 1][j - 1], dp[i][j] * 1ll * 4 * j % mod);
// put > and <
if (j > 1) add(dp[i + 1][j - 2], dp[i][j] * 1ll * (j * (j - 1) / 2) % mod);
// put v and ^
if (i + 2 <= n && j > 0) add(dp[i + 2][j - 1], dp[i][j] * 1ll * (n - i - 1) * j % mod);
}
}
int ans = -1;
rep(i, 0, m) add(ans, dp[n][i]);
cout << ans;
ioi
}
/*
5116 0
3720 1
450 2
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
1016 KB |
Output is correct |
5 |
Correct |
3 ms |
632 KB |
Output is correct |
6 |
Correct |
4 ms |
1272 KB |
Output is correct |
7 |
Correct |
3 ms |
760 KB |
Output is correct |
8 |
Correct |
3 ms |
1404 KB |
Output is correct |
9 |
Correct |
3 ms |
888 KB |
Output is correct |
10 |
Correct |
5 ms |
1656 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
6 ms |
1912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
1016 KB |
Output is correct |
5 |
Correct |
3 ms |
632 KB |
Output is correct |
6 |
Correct |
4 ms |
1272 KB |
Output is correct |
7 |
Correct |
3 ms |
760 KB |
Output is correct |
8 |
Correct |
3 ms |
1404 KB |
Output is correct |
9 |
Correct |
3 ms |
888 KB |
Output is correct |
10 |
Correct |
5 ms |
1656 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
6 ms |
1912 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
13 ms |
9596 KB |
Output is correct |
15 |
Correct |
175 ms |
32912 KB |
Output is correct |
16 |
Correct |
9 ms |
2680 KB |
Output is correct |
17 |
Correct |
32 ms |
7928 KB |
Output is correct |
18 |
Correct |
50 ms |
11000 KB |
Output is correct |
19 |
Correct |
199 ms |
34556 KB |
Output is correct |
20 |
Correct |
158 ms |
29060 KB |
Output is correct |
21 |
Correct |
101 ms |
19836 KB |
Output is correct |
22 |
Correct |
109 ms |
22264 KB |
Output is correct |
23 |
Correct |
74 ms |
19832 KB |
Output is correct |
24 |
Correct |
251 ms |
35576 KB |
Output is correct |
25 |
Correct |
192 ms |
30736 KB |
Output is correct |
26 |
Correct |
219 ms |
33536 KB |
Output is correct |
27 |
Correct |
241 ms |
34664 KB |
Output is correct |