Submission #1118205

#TimeUsernameProblemLanguageResultExecution timeMemory
1118205vjudge1Kangaroo (CEOI16_kangaroo)C++17
6 / 100
1 ms336 KiB
#include <bits/stdc++.h> using namespace std; int main() { constexpr int MOD = 1000000007; int n, cs, cf; cin >> n >> cs >> cf; vector<vector<int>> dp(n + 3, vector<int>(n + 3, 0)); dp[1][1] = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i == cs or i == cf) { dp[i][j] += dp[i - 1][j]; dp[i][j + 1] += dp[i - 1][j]; dp[i][j] %= MOD; dp[i][j + 1] %= MOD; continue; } dp[i][j - 1] += dp[i - 1][j] * (j - 1); dp[i][j + 1] += dp[i - 1][j] * (j + 1 - (int)(i > cs) - (int)(i > cf)); dp[i][j - 1] %= MOD; dp[i][j + 1] %= MOD; } } cout << dp[n][1] << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...