# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
545903 | rainboy | Kangaroo (CEOI16_kangaroo) | C11 | 14 ms | 304 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.
#include <stdio.h>
#include <string.h>
#define N 2000
#define MD 1000000007
int main() {
static int dp[N], dq[N];
int n, s, f, i, j, k;
scanf("%d%d%d", &n, &s, &f), s--, f--;
dp[0] = 1, k = 0;
for (i = 0; i < n - 1; i++) {
memset(dq, 0, n * sizeof *dq);
if (i == s || i == f) {
k++;
for (j = 0; j < n; j++)
dq[j] = (dp[j] + (j + 1 == n ? 0 : (long long) dp[j + 1] * (j + 1))) % MD;
} else
for (j = 0; j < n; j++)
dq[j] = ((j + 1 == n ? 0 : (long long) dp[j + 1] * (j + 1) * (j + k)) + (j == 0 ? 0 : dp[j - 1])) % MD;
memcpy(dp, dq, n * sizeof *dq);
}
printf("%d\n", dp[0]);
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... |