Submission #1005210

#TimeUsernameProblemLanguageResultExecution timeMemory
1005210milisavKangaroo (CEOI16_kangaroo)C++14
100 / 100
10 ms16220 KiB
#include <bits/stdc++.h> #define maxn 2024 using namespace std; const int mod = 1000000007; int n, cs, cf; int dp[maxn][maxn]; int main() { cin.tie(0); ios_base::sync_with_stdio(false); cin>>n>>cs>>cf; if(n==2) { cout<<1<<endl; return 0; } if(cf==1 || cs==1) dp[1][0]=1; else dp[1][1] = 1; for(int i=2;i<=n;i++) { for(long long g=0;g<=i;g++) { if(i<cs && i<cf) { dp[i][g] = ((g?dp[i-1][g-1]:0) + g*(g+1)*dp[i-1][g+1])%mod; continue; } if(i==cs || i==cf) { dp[i][g] = (dp[i-1][g] + (g+1)*dp[i-1][g+1])%mod; continue; } if(i>cf && i>cs) { dp[i][g] = ((g?dp[i-1][g-1]:0) + (g+2)*(g+1)*dp[i-1][g+1])%mod; continue; } else { dp[i][g] = ((g?dp[i-1][g-1]:0) + (g+1)*(g+1)*dp[i-1][g+1])%mod; continue; } } } cout<<dp[n-1][0]<<endl; 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...