Submission #1168788

#TimeUsernameProblemLanguageResultExecution timeMemory
1168788spycoderytKangaroo (CEOI16_kangaroo)C++20
0 / 100
0 ms324 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; void add(int &a,int b){ a = (a + b) % mod; } int32_t main() { int n,st,en,diff=0; cin >> n >> st >> en; dp[1][1] = 1; for(int i = 1;i<=n+1;i++) { for(int j = 1;j<=i;j++) { if(i == st || i == en) { add(dp[i+1][j],dp[i][j]); add(dp[i+1][j+1],dp[i][j]); } else { add(dp[i+1][j+1],dp[i][j] * (j - (i > st) - (i > en) + 1)); // new cmp if(j-1>=1)add(dp[i+1][j-1],dp[i][j] * (j-1)); // merge } // cerr << dp[i][j] << " "; } // cerr<<'\n'; } cout << dp[n+1][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...