Submission #741051

#TimeUsernameProblemLanguageResultExecution timeMemory
741051NemanjaSo2005Kangaroo (CEOI16_kangaroo)C++14
100 / 100
21 ms31648 KiB
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
ll dp[2005][2005],S,T,N,uze;
int main(){
   cin>>N>>S>>T;
   dp[1][1]=1;
   if(S==1 or T==1){
      uze=1;
   }
   for(int i=2;i<=N;i++){
      if(i==S or i==T){
         uze++;
         for(int j=1;j<=N;j++)
            dp[i][j]=(dp[i-1][j-1]+dp[i-1][j])%MOD;
         continue;
      }
      for(int j=1;j<=N;j++){
         dp[i][j]=((j-uze)*dp[i-1][j-1] + j*dp[i-1][j+1])%MOD;
      }
   }
   cout<<dp[N][1]<<"\n";
   return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...