This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
ll dp[2005][2005],S,T,N,uze;
int main(){
cin>>N>>S>>T;
dp[1][1]=1;
if(S==1 or T==1){
uze=1;
}
for(int i=2;i<=N;i++){
if(i==S or i==T){
uze++;
for(int j=1;j<=N;j++)
dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
continue;
}
for(int j=1;j<=N;j++){
dp[i][j]=(j-uze)*dp[i-1][j-1] + j*dp[i-1][j+1];
}
}
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... |