이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second
const int mod = 1000000007;
const int mxn = 2001;
int n, x, y;
int dp[2][mxn];
int r;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> x >> y;
dp[r++][0] = 1;
for(int i = 1, l = 0; i <= n; i++, r ^= 1){
int t = i == x || i == y;
dp[r][0] = 0;
for(int j = 1; j <= n; j++){
if(t){
dp[r][j] = (dp[!r][j] + dp[!r][j - 1]) % mod;
}else{
dp[r][j] = ((ll)max(0, j - l) * dp[!r][j - 1] + (ll)j * dp[!r][j + 1]) % mod;
}
}
l += t;
}
r ^= 1;
cout << dp[r][1] << endl;
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... |