제출 #1327206

#제출 시각아이디문제언어결과실행 시간메모리
1327206Double_SlashKangaroo (CEOI16_kangaroo)C++20
100 / 100
31 ms31664 KiB
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
const ll MOD = 1e9 + 7;
int n, s, f;
ll dp[2002][2002];
 
int main() {
    cin >> n >> s >> f;
    dp[1][1] = 1;
    for (int i = 2; i <= n; ++i) {
        if (i == s or i == f) {
            for (int j = 1; j <= n; ++j) {
                dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % MOD;
                dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
            }
        } else {
            for (int j = 1; j <= n; ++j) {
                dp[i][j] = (dp[i][j] + dp[i - 1][j - 1] * (j - (i > s) - (i > f))) % MOD;
                dp[i][j] = (dp[i][j] + dp[i - 1][j + 1] * j) % MOD;
            }
        }
    }
    cout << dp[n][1] << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...