# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
160590 | Akashi | Kangaroo (CEOI16_kangaroo) | C++14 | 28 ms | 14200 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int n, l, r;
int d[2005][2005];
int main()
{
// freopen("kangaroo.in", "r", stdin);
// freopen("kangaroo.out", "w", stdout);
scanf("%d%d%d", &n, &l, &r);
d[0][0] = 1;
int nr = 0;
for(int i = 1; i <= n ; ++i){
if(i != l && i != r){
///create a new component
for(int k = 1; k <= i ; ++k)
d[i][k] = (d[i][k] + 1LL * d[i - 1][k - 1] * (k - nr)) % MOD;
///merge two components
for(int k = 1; k <= i ; ++k)
d[i][k] = (d[i][k] + 1LL * d[i - 1][k + 1] * k) % MOD;
}
else{
++nr;
for(int k = 1; k <= i ; ++k){
d[i][k] = d[i - 1][k - 1] + d[i - 1][k];
if(d[i][k] >= MOD) d[i][k] -= MOD;
}
}
}
printf("%d", d[n][1]);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |