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>
using namespace std;
#define ll long long
const int MAXN = 205;
const int MOD = 1e9+7;
ll dp[MAXN][MAXN][MAXN][2];
ll f(int n, int s, int t, int dir) {
if (dp[n][s][t][dir] != -1) return dp[n][s][t][dir];
if (s == t) return dp[n][s][t][dir] = 0;
ll ans = 0;
int tt = t-(s<t);
if (dir) {
for (int i = 1; i < s; ++i) {
ans += f(n-1,i,tt,0);
ans %= MOD;
}
} else {
for (int i = s+1; i <= n; ++i) {
ans += f(n-1, i-1, tt, 1);
ans %= MOD;
}
}
return dp[n][s][t][dir] = ans;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n, cs, cf; cin >> n >> cs >> cf;
memset(dp, -1, sizeof(dp));
dp[1][1][1][0] = 1;
dp[1][1][1][1] = 1;
cout << f(n,cs,cf,0) + f(n,cs,cf,1) % MOD<<"\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... |