# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
643392 |
2022-09-22T00:24:30 Z |
danikoynov |
NoM (RMI21_nom) |
C++14 |
|
220 ms |
63196 KB |
/**
____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|
**/
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 2010;
const ll mod = 1e9 + 7;
int n, m;
ll dp[maxn][maxn], ch[maxn][maxn], t[maxn], f[maxn];
void solve()
{
cin >> n >> m;
for (int i = 1; i <= m; i ++)
{
int cnt = (2 * n - i) / m + 1;
t[i] = cnt;
}
for (int i = 0; i <= max(n, m); i ++)
ch[i][0] = 1;
for (int i = 1; i <= max(n, m); i ++)
for (int j = 1; j <= max(n, m); j ++)
{
ch[i][j] = ch[i - 1][j - 1] + ch[i - 1][j];
if (ch[i][j] >= mod)
ch[i][j] -= mod;
}
f[0] = 1;
for (ll i = 1; i <= (ll)max(n, m); i ++)
{
f[i] = (f[i - 1] * i) % mod;
}
dp[0][0] = 1;
for (int i = 0; i < m; i ++)
for (int j = 0; j <= n; j ++)
{
for (int k = max((ll)(0), t[i + 1] - j); k <= t[i + 1]; k ++)
{
dp[i + 1][j + k - (t[i + 1] - k)] += (((((dp[i][j] * ch[j][t[i + 1] - k]) % mod) * ch[t[i + 1]][t[i + 1] - k]) % mod) * f[t[i + 1] - k]) % mod;
///cout << i << " " << j << " " << k << " " << i + 1 << " " << j + k - (t[i + 1] - k) << endl;
if (dp[i + 1][j + k - (t[i + 1] - k)] >= mod)
dp[i + 1][j + k - (t[i + 1] - k)] -= mod;
}
///cout << dp[i][j] << " ";
}
///cout << dp[m][0] << endl;
ll ans = dp[m][0];
for (ll i = 1; i <= n; i ++)
ans = (((ans * i) % mod) * (ll)(2)) % mod;
cout << ans << endl;
}
int main()
{
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
304 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
304 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
980 KB |
Output is correct |
12 |
Correct |
1 ms |
852 KB |
Output is correct |
13 |
Correct |
1 ms |
596 KB |
Output is correct |
14 |
Correct |
1 ms |
724 KB |
Output is correct |
15 |
Correct |
1 ms |
932 KB |
Output is correct |
16 |
Correct |
1 ms |
724 KB |
Output is correct |
17 |
Correct |
1 ms |
724 KB |
Output is correct |
18 |
Correct |
1 ms |
852 KB |
Output is correct |
19 |
Correct |
1 ms |
692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
304 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
980 KB |
Output is correct |
12 |
Correct |
1 ms |
852 KB |
Output is correct |
13 |
Correct |
1 ms |
596 KB |
Output is correct |
14 |
Correct |
1 ms |
724 KB |
Output is correct |
15 |
Correct |
1 ms |
932 KB |
Output is correct |
16 |
Correct |
1 ms |
724 KB |
Output is correct |
17 |
Correct |
1 ms |
724 KB |
Output is correct |
18 |
Correct |
1 ms |
852 KB |
Output is correct |
19 |
Correct |
1 ms |
692 KB |
Output is correct |
20 |
Correct |
2 ms |
1236 KB |
Output is correct |
21 |
Correct |
2 ms |
1492 KB |
Output is correct |
22 |
Correct |
4 ms |
3412 KB |
Output is correct |
23 |
Correct |
2 ms |
1840 KB |
Output is correct |
24 |
Correct |
4 ms |
3028 KB |
Output is correct |
25 |
Correct |
3 ms |
3284 KB |
Output is correct |
26 |
Correct |
2 ms |
1968 KB |
Output is correct |
27 |
Correct |
5 ms |
4052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
304 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
980 KB |
Output is correct |
12 |
Correct |
1 ms |
852 KB |
Output is correct |
13 |
Correct |
1 ms |
596 KB |
Output is correct |
14 |
Correct |
1 ms |
724 KB |
Output is correct |
15 |
Correct |
1 ms |
932 KB |
Output is correct |
16 |
Correct |
1 ms |
724 KB |
Output is correct |
17 |
Correct |
1 ms |
724 KB |
Output is correct |
18 |
Correct |
1 ms |
852 KB |
Output is correct |
19 |
Correct |
1 ms |
692 KB |
Output is correct |
20 |
Correct |
2 ms |
1236 KB |
Output is correct |
21 |
Correct |
2 ms |
1492 KB |
Output is correct |
22 |
Correct |
4 ms |
3412 KB |
Output is correct |
23 |
Correct |
2 ms |
1840 KB |
Output is correct |
24 |
Correct |
4 ms |
3028 KB |
Output is correct |
25 |
Correct |
3 ms |
3284 KB |
Output is correct |
26 |
Correct |
2 ms |
1968 KB |
Output is correct |
27 |
Correct |
5 ms |
4052 KB |
Output is correct |
28 |
Correct |
9 ms |
6100 KB |
Output is correct |
29 |
Correct |
13 ms |
9268 KB |
Output is correct |
30 |
Correct |
18 ms |
11448 KB |
Output is correct |
31 |
Correct |
9 ms |
6100 KB |
Output is correct |
32 |
Correct |
15 ms |
9980 KB |
Output is correct |
33 |
Correct |
20 ms |
13328 KB |
Output is correct |
34 |
Correct |
35 ms |
20208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
304 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
980 KB |
Output is correct |
12 |
Correct |
1 ms |
852 KB |
Output is correct |
13 |
Correct |
1 ms |
596 KB |
Output is correct |
14 |
Correct |
1 ms |
724 KB |
Output is correct |
15 |
Correct |
1 ms |
932 KB |
Output is correct |
16 |
Correct |
1 ms |
724 KB |
Output is correct |
17 |
Correct |
1 ms |
724 KB |
Output is correct |
18 |
Correct |
1 ms |
852 KB |
Output is correct |
19 |
Correct |
1 ms |
692 KB |
Output is correct |
20 |
Correct |
2 ms |
1236 KB |
Output is correct |
21 |
Correct |
2 ms |
1492 KB |
Output is correct |
22 |
Correct |
4 ms |
3412 KB |
Output is correct |
23 |
Correct |
2 ms |
1840 KB |
Output is correct |
24 |
Correct |
4 ms |
3028 KB |
Output is correct |
25 |
Correct |
3 ms |
3284 KB |
Output is correct |
26 |
Correct |
2 ms |
1968 KB |
Output is correct |
27 |
Correct |
5 ms |
4052 KB |
Output is correct |
28 |
Correct |
9 ms |
6100 KB |
Output is correct |
29 |
Correct |
13 ms |
9268 KB |
Output is correct |
30 |
Correct |
18 ms |
11448 KB |
Output is correct |
31 |
Correct |
9 ms |
6100 KB |
Output is correct |
32 |
Correct |
15 ms |
9980 KB |
Output is correct |
33 |
Correct |
20 ms |
13328 KB |
Output is correct |
34 |
Correct |
35 ms |
20208 KB |
Output is correct |
35 |
Correct |
53 ms |
26044 KB |
Output is correct |
36 |
Correct |
169 ms |
54780 KB |
Output is correct |
37 |
Correct |
53 ms |
25792 KB |
Output is correct |
38 |
Correct |
109 ms |
39068 KB |
Output is correct |
39 |
Correct |
123 ms |
48788 KB |
Output is correct |
40 |
Correct |
220 ms |
63196 KB |
Output is correct |