Submission #1168774

#TimeUsernameProblemLanguageResultExecution timeMemory
1168774spycoderytKangaroo (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;i++) { for(int j = 1;j<=i;j++) { if(i == st || i == en) { // add new add(dp[i+1][j+1],dp[i][j]); // add to existing cmp add(dp[i+1][j], dp[i][j]); diff++; } else { // new cmp (use 3) if(i+1!=st&&i+1!=en&&i+2!=st&&i+2!=en){ add(dp[i+3][j+1], dp[i][j] * 2 * (j - diff + 1)); } // add to cmp add(dp[i+1][j], dp[i][j] * (j - diff) * 2); // merge cmp if(j-1>=1)add(dp[i+1][j-1], dp[i][j] * (j-1)); } // 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...