Submission #1168790

#TimeUsernameProblemLanguageResultExecution timeMemory
1168790spycoderytKangaroo (CEOI16_kangaroo)C++20
100 / 100
14 ms23112 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int N = 2005; int dp[N][N]; const int mod = 1e9+7; int add(int a,int b){ return (a + b) % mod; } int mul(int a,int b) { return (a * b) % mod; } int32_t main() { int n,st,en,diff=0; cin >> n >> st >> en; dp[1][1] = 1; for(int i = 2;i<=n;i++) { for(int j = 1;j<=i;j++) { if(i == st || i == en) { dp[i][j]=add(dp[i-1][j-1],dp[i-1][j]); } else { dp[i][j]=add(mul(dp[i-1][j-1],j-(i>st)-(i>en)),mul(dp[i-1][j+1],j)); } // cerr << dp[i][j] << " "; } // cerr<<'\n'; } cout << dp[n][1]; } /* no 3 can be increasing 2x or decreasing 2x want to use the same update so force structure into the problme */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...