# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
23897 | khsoo01 | Kangaroo (CEOI16_kangaroo) | C++11 | 26 ms | 33424 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;
typedef long long ll;
const ll mod = 1e9+7;
ll n, s, e, dt[2005][2005];
ll solve (ll X, ll Y) {
dt[n+1][0] = 1;
ll ocu = 0;
for(int i=n;i>=1;i--) {
for(int j=1;j<=n-i+1;j++) {
if(i == s) dt[i][j] = dt[i+1][j-X];
else if(i == e) dt[i][j] = dt[i+1][j-Y];
else dt[i][j] = (dt[i+1][j-1] * (j - ocu) + dt[i+1][j+1] * j) % mod;
}
if(i == s || i == e) ocu++;
}
return dt[1][1];
}
int main()
{
scanf("%lld%lld%lld",&n,&s,&e);
printf("%lld\n",(solve(0, (n+1)%2) + solve(1, n%2)) % mod);
}
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... |