제출 #493907

#제출 시각아이디문제언어결과실행 시간메모리
493907khoabright캥거루 (CEOI16_kangaroo)C++17
6 / 100
1 ms332 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define ff first #define ss second #define pb push_back #define rep(i, a, b) for (int i = (int)a; i <= (int)b; ++i) #define rep1(i, a, b) for (int i = (int)a; i >= (int)b; --i) #define all(x) x.begin(), x.end() const int N = 2e3 + 5; const int mod = 1e9 + 7; int dp[N][N]; int main() { int n, a, b; cin >> n >> a >> b; dp[1][1] = 1; rep(i, 1, n - 1) rep(j, 1, i) { if (i + 1 == a || i + 1 == b) { (dp[i + 1][j] += dp[i][j]) %= mod; (dp[i + 1][j + 1] += dp[i][j]) %= mod; } else { // merge two components (dp[i + 1][j - 1] += dp[i][j] * (j - 1)) %= mod; // create a new component (dp[i + 1][j + 1] += (dp[i][j] * (j + 1 - (i + 1 > a) - (i + 1 > b)))) %= 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...