# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
136163 | dragonslayerit | Kangaroo (CEOI16_kangaroo) | C++14 | 39 ms | 15996 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 <cstdio>
const int MOD=1e9+7;
int dp[2001][2001];//index,#ccs
void addmod(int& x,long long y){
x=(x+y)%MOD;
}
int main(){
int N,S,T;
scanf("%d %d %d",&N,&S,&T);
S--,T--;
dp[0][0]=1;
for(int i=0;i<N;i++){
if(i==S||i==T){
for(int cc=0;cc<N;cc++){
if(cc) addmod(dp[i+1][cc],dp[i][cc]);
addmod(dp[i+1][cc+1],dp[i][cc]);
}
}else{
for(int cc=0;cc<N;cc++){
addmod(dp[i+1][cc+1],dp[i][cc]*1LL*(cc+1-(i>S)-(i>T)));
if(cc>0) addmod(dp[i+1][cc-1],dp[i][cc]*1LL*(cc-1));
}
}
}
printf("%d\n",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... |