Submission #1174882

#TimeUsernameProblemLanguageResultExecution timeMemory
1174882nguyenkhangninh99캥거루 (CEOI16_kangaroo)C++17
100 / 100
29 ms23112 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int maxn = 2e3 + 5, mod = 1e9 + 7; int dp[maxn][maxn]; signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, cs, cf; cin >> n >> cs >> cf; dp[1][1] = 1; for(int i = 1; i < n; i++){ for(int j = 1; j <= i; j++){ if(i + 1 == cs || i + 1 == cf){ (dp[i + 1][j] += dp[i][j]) %= mod; (dp[i + 1][j + 1] += dp[i][j]) %= mod; } else{ (dp[i + 1][j - 1] += dp[i][j] * (j - 1)) %= mod; (dp[i + 1][j + 1] += dp[i][j] * (j + 1 - (i + 1 > cs) - (i + 1 > cf))) %= mod; } } } cout << dp[n][1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...