#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define all(x) x.begin(), x.end()
int M = 1e9 + 7;
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
// freopen("kangaroo.in", "r", stdin);
// freopen("kangaroo.out", "w", stdout);
int n, s, t;
cin >> n >> s >> t;
vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(n, vector<int>(n + 1)));
s--, t--;
int ans = 0;
dp[s][t][n] = 1;
s = n - s - 1;
t = n - t - 1;
dp[s][t][n] = 1;
for (int z = n; z > 1; z--)
for (int x = 0; x < z; x++)
for (int y = 0; y < z; y++)
{
if (z != n && x)
dp[x][y][z] += dp[x - 1][y][z];
if (x == y || dp[x][y][z] == 0)
continue;
// for (int i = 0; i < z; i++)
// {
// if (x == i)
// continue;
// if ((i < x) ^ (z % 2))
// continue;
// int l = (i - (i > x));
// int r = (y - (y > x));
// (dp[l][r][z - 1] += dp[x][y][z]) %= M;
// }
if (z % 2 == 0)
(dp[x + 1][y - (y > x)][z - 1] += dp[x][y][z]) %= M;
else
(dp[0][y - (y > x)][z - 1] += dp[x][y][z]) %= M, (dp[x][y - (y > x)][z - 1] -= dp[x][y][z] - M) %= M;
}
ans = dp[0][0][1];
cout << ans % M;
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... |