이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N_MAX = 2000;
const int MOD = (int) 1e9 + 7;
int N, L, R;
int dp[N_MAX + 2][N_MAX + 2];
int main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> N >> L >> R;
dp[0][1] = 1;
for (int i = 1; i <= N; i++) {
for (int open = 0; open <= N; open++) {
if (i == L || i == R) {
dp[i][open] += dp[i - 1][open];
if (dp[i][open] >= MOD) {
dp[i][open] -= MOD;
}
dp[i][open - 1] += dp[i - 1][open];
if (dp[i][open - 1] >= MOD) {
dp[i][open - 1] -= MOD;
}
} else {
dp[i][open + 1] = (dp[i][open + 1] + (ll) dp[i - 1][open] * open) % MOD;
dp[i][open - 1] = (dp[i][open - 1] + (ll) dp[i - 1][open] * max(0, open - (i < L) - (i < R))) % MOD;
}
}
}
cout << dp[N][0] << "\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... |