# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
559559 | Pherokung | Kangaroo (CEOI16_kangaroo) | C++14 | 0 ms | 212 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;
#define N 2005
#define ll long long
const int mod = 1e9+7;
int n,cs,cf,del;
ll dp[N][N],ans;
int main(){
scanf("%d%d%d",&n,&cs,&cf);
dp[0][0] = 1;
for(int idx=1;idx<=n;idx++){
for(int comp=1;comp<=idx;comp++){
if(idx == cs || idx == cf){
dp[idx][comp] += dp[idx-1][comp];
dp[idx][comp] += dp[idx-1][comp-1];
del++;
}
else{
if(comp * 2 - del > 0) dp[idx][comp] += dp[idx-1][comp] * (comp * 2 - del);
if(comp - del > 0) dp[idx][comp] += dp[idx-1][comp-1] * (comp - del);
dp[idx][comp] += dp[idx-1][comp+1] * (comp);
}
// printf("?? %d %d : %lld\n",idx,comp,dp[idx][comp]);
dp[idx][comp] %= mod;
}
}
printf("%lld",dp[n][1]);
}
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... |