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 MOD 1000000007
using namespace std;
long long N, cs, cf, dp[2500][2500];
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin>>N>>cs>>cf;
dp[0][0]=1;
for(int i=1; i<=N; i++) {
for(int j=1; j<=N; j++) {
if(i==cs||i==cf) {
dp[i][j]=dp[i-1][j]+dp[i-1][j-1];
}
else dp[i][j]=(j-(i>cs)-(i>cf))*dp[i-1][j-1]+(j*(j+1)/2)*dp[i-1][j+1];
}
}
cout<<dp[N][1];
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... |