Submission #1282294

#TimeUsernameProblemLanguageResultExecution timeMemory
1282294Ekber_EkberKangaroo (CEOI16_kangaroo)C++20
0 / 100
1 ms568 KiB
#include <bits/stdc++.h>
#define GOOD_LUCK ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;

constexpr int MAX = 2e+5 + 1, INF = 2e+16, MOD = 1e+9 + 7, K = 31;

void _() {
	int n, a, b;
	cin >> n >> a >> b;
	vector <vector <int>> dp(n+1, vector <int>(n+2, 0));
	// dp[0][0] = 1;
	dp[1][1] = 1;
	int x=0;
	for (int i = 1; i <= n; i++) {
		if (i == a) x++;
		if (i == b) x++;
		for (int j = 1; j <= i; j++) {
			if (i == a || i == b) {
				dp[i][j] += dp[i-1][j];
				dp[i][j] += dp[i-1][j-1];
			}
			else {
				dp[i][j] += dp[i-1][j-1] * (j - x);
				dp[i][j] += dp[i-1][j+1] * (j - 1);
			}
			dp[i][j] %= MOD;
		}
	}
	cout << dp[n][n];
}

signed main() {

	GOOD_LUCK

	int tests=1;
	// cin >> tests;
	for (int i=1; i <= tests; i++) {
		_();
		cout << endl;
	}

	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...