Submission #1332394

#TimeUsernameProblemLanguageResultExecution timeMemory
1332394blackscreen1Kangaroo (CEOI16_kangaroo)C++20
100 / 100
16 ms23048 KiB
#include <bits//stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_multiset;
#define ll long long
#define iloop(m, h) for (auto i = m; i != h; i += (m < h ? 1 : -1))
#define jloop(m, h) for (auto j = m; j != h; j += (m < h ? 1 : -1))
#define kloop(m, h) for (auto k = m; k != h; k += (m < h ? 1 : -1))
#define lloop(m, h) for (auto l = m; l != h; l += (m < h ? 1 : -1))
#define pll pair<ll, ll>
#define INF 1000000000000000
#define MOD1 1000000007
#define MOD2 998244353
#define MOD3 1000000009
ll n, x, y;
ll dp[2005][2005];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> x >> y;
	iloop(1, n+1) jloop(1, i+1) {
		if (i + j == 2) {dp[i][j] = 1; continue;}
		if (i == x || i == y) {dp[i][j] = (dp[i-1][j] + dp[i-1][j-1])%MOD1; continue;}
		dp[i][j] = j;
		if (i >= x) dp[i][j]--;
		if (i >= y) dp[i][j]--;
		dp[i][j] *= dp[i-1][j-1];
		dp[i][j] += dp[i-1][j+1] * j;
		dp[i][j] %= MOD1;
	}
	cout << dp[n][1];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...