이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;
const int mxn=2e3+5;
const int inf=1e9;
const ll mod = 1e9 + 7;
int main() {
int n,cf,cs;
cin >> n >> cf >> cs;
ll dp[n + 1][n + 1] = {};
dp[1][1] = 1;
int k = (1 == cs || 1 == cf);
for(ll i = 2; i <= n; i++) {
if(i == cf || i == cs) k++;
for(ll j = 1; j <= i; j++) {
if(i == cf || i == cs) {
dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % mod;
continue;
}
dp[i][j] = (j - k) * dp[i - 1][j - 1] % mod;
dp[i][j] += j * dp[i - 1][j + 1] % mod;
dp[i][j] %= mod;
}
}
cout<<dp[n][1]<<endl;
}
# | 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... |