#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
#define ll long long
#define ld long double
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define isz(x) (int)(x.size())
#define vi vector<int>
#define vvi vector<vi>
#define ost tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update>
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int sz = 205, inf = 1000000000;
const ll mod = 1000000007, INF = 1000000000000000000;
int dp[sz][sz][sz][2];
// 0 -> increasing
// 1 -> decreasing
void solve() {
int n, cs, cf;
cin >> n >> cs >> cf;
memset(dp, 0, sizeof(dp));
dp[2][1][2][0] = 1;
dp[2][2][1][1] = 1;
for (int i = 3; i <= n; i++) {
for (int s = 1; s <= i; s++) {
for (int f = 1; f <= i; f++) {
if (s == f) continue;
for (int k = s; k < i; k++)
dp[i][s][f][0] += dp[i-1][k][f - (f > s)][1];
for (int k = 1; k < s; k++)
dp[i][s][f][1] += dp[i-1][k][f - (f > s)][0];
}
}
}
cout << dp[n][cs][cf][0] + dp[n][cs][cf][1] << '\n';
}
void precompute() {}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef LOCAL
freopen("err.log", "w", stderr);
freopen("in.txt", "r", stdin);
#endif
precompute();
solve();
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... |