Submission #552940

#TimeUsernameProblemLanguageResultExecution timeMemory
552940JomnoiKangaroo (CEOI16_kangaroo)C++17
100 / 100
33 ms16016 KiB
#include <bits/stdc++.h> #define DEBUG false using namespace std; const int MAX_N = 2e3 + 10; const int MOD = 1e9 + 7; int dp[MAX_N][MAX_N]; int main() { cin.tie(nullptr)->sync_with_stdio(false); int N, cs, cf; cin >> N >> cs >> cf; dp[1][1] = 1; for(int i = 2; i <= N; i++) { for(int j = 1; j <= N; j++) { if(i == cs or i == cf) { dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % MOD; dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD; } else { int v = j - (i > cs) - (i > cf); dp[i][j] = (dp[i][j] + 1ll*j * dp[i - 1][j + 1]) % MOD; dp[i][j] = (dp[i][j] + 1ll*v * dp[i - 1][j - 1]) % MOD; } } } 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...