# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
442635 | parsabahrami | Kangaroo (CEOI16_kangaroo) | C++17 | 39 ms | 15976 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/* I do it for the glory */
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
#define SZ(x) (int) x.size()
#define F first
#define S second
const int N = 2e3 + 10, MOD = 1e9 + 7;
int n, s, e, dp[N][N];
int main() {
scanf("%d%d%d", &n, &s, &e);
dp[1][1] = 1;
for (int i = 2; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (i == s || i == e) dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % MOD;
else {
int x = j;
if (i > s) x--;
if (i > e) x--;
dp[i][j] = (1ll * dp[i - 1][j + 1] * j % MOD + dp[i - 1][j - 1] * 1ll * x % MOD) % MOD;
}
}
}
printf("%d\n", dp[n][1]);
return 0;
}
Compilation message (stderr)
# | 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... |