# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
975490 | duckindog | Kangaroo (CEOI16_kangaroo) | C++17 | 4 ms | 16220 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 <bits/stdc++.h>
using namespace std;
const int N = 2'000 + 10,
M = 1'000'000'007;
int n, st, ed;
struct modint {
int value;
modint(int x = 0) : value(x) {}
modint operator + (const modint& rhs) { return (value + rhs.value) % M; }
modint operator - (const modint& rhs) { return ((value - rhs.value) % M + M) % M; }
modint operator * (const modint& rhs) { return 1ll * value * rhs.value % M; }
modint operator += (const modint& rhs) { value = (value + rhs.value) % M; return *this; }
modint operator -= (const modint& rhs) { value = ((value - rhs.value) % M + M) % M; return *this; }
modint operator *= (const modint& rhs) { value = 1ll * value * rhs.value % M; return *this; }
friend ostream& operator << (ostream& os, const auto& rhs) { return os << rhs.value; }
} f[N][N];
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> st >> ed;
f[1][1] = 1;
for (int i = 2; i <= n; ++i) {
for (int j = 1; j <= i; ++j) {
auto& ret = f[i][j];
if (i == st || i == ed) ret = f[i - 1][j] + f[i][j - 1];
else ret = f[i - 1][j + 1] * j + f[i - 1][j - 1] * (j - (i > st) - (i > ed));
}
}
cout << f[n][1] << "\n";
}
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... |