Submission #813215

#TimeUsernameProblemLanguageResultExecution timeMemory
813215WarinchaiKangaroo (CEOI16_kangaroo)C++14
0 / 100
0 ms212 KiB
#include<bits/stdc++.h> using namespace std; long long dp[2005][2005]; long long md=1e9+7; int k; int main(){ int n,st,en; cin>>n>>st>>en; if(st==en){ cout<<1; } dp[0][1]=1; dp[1][1]=1; for(int i=1;i<=n;i++){ if(i==st||i==en){ k++; } for(int j=1;j<=n;j++){ if(i==st||i==en){ dp[i][j-1]+=dp[i-1][j]; dp[i][j]+=dp[i-1][j]; dp[i][j]%=md; dp[i][j-1]%=md; }else{ dp[i][j+1]+=dp[i-1][j]*(j+1-k); dp[i][j-1]+=dp[i-1][j]*(j-1); dp[i][j+1]%=md; dp[i][j-1]%=md; } } } cout<<dp[n][1]; // cout<<"\n"<<k; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...