이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
 *    author:  longvu
 *    created: 10/06/22 10:25:38
**/
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
const int INF = numeric_limits<int>::max();
const int nax = (int)(2901);
const int mod = 1e9 + 7;
 
template<class X, class Y>
bool maximize(X& x, const Y y) {
    if (y > x) {x = y; return true;}
    return false;
}
template<class X, class Y>
bool minimize(X& x, const Y y) {
    if (y < x) {x = y; return true;}
    return false;
}
 
int dp[nax][nax];
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, st, ed;
    cin >> n >> st >> ed;
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= n; ++j) {
            if (i + 1 == st || i + 1 == ed) {
                (dp[i + 1][j + 1] += dp[i][j]) %= mod;
              	if (j) {
                	(dp[i + 1][j] += dp[i][j]) %= mod;
                }
                continue;
            }
            if (j) {
                (dp[i + 1][j - 1] += (j - 1) * dp[i][j] % mod) %= mod;
            }
            (dp[i + 1][j + 1] += (j + 1 - (i + 1 >= st) - (i + 1 >= ed)) * dp[i][j] % mod) %= mod;
        }
    }
    cout << dp[n][1] << '\n';
    return 0;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |