Submission #495324

#TimeUsernameProblemLanguageResultExecution timeMemory
495324VladMKangaroo (CEOI16_kangaroo)C++14
6 / 100
1 ms336 KiB
#include <bits/stdc++.h> using namespace std; #define modulo 1000000007 long long n, dp[2007][2007], f, cs, cf; int main() { cin>>n>>cs>>cf; dp[0][0]=1; for(int i=1; i<=n; i++){ for(int j=1; j<=n; j++){ if(i==cs || i==cf){ dp[i][j]=dp[i-1][j-1]+dp[i-1][j]; continue; } if(i<cs) dp[i][j]=j*(dp[i-1][j-1]+dp[i-1][j+1]); else if(i<cf) dp[i][j]=dp[i-1][j-1]*(j-1)+dp[i-1][j+1]*j; else dp[i][j]=dp[i-1][j-1]*(j-2)+dp[i-1][j+1]*j; } } cout<<dp[n][1]; 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...