This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// it is your desire to work hard
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int maxn=2e3+3;
const int mod=1e9+7;
int n;
int dp[maxn][maxn];
int cs, cf;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n;
cin>>cs>>cf;
dp[1][1]=1;
for(int i=2; i<=n; i++){
for(int j=1; j<=i; j++){
int rem=0;
if(i>cs) rem++;
if(i>cf) rem++;
if(i==cs or i==cf){
dp[i][j] = dp[i-1][j-1] + dp[i-1][j];
}else{
dp[i][j] += dp[i-1][j+1]*j + dp[i-1][j-1]*(j-rem);
}
}
}
cout<<dp[n][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... |