# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
806989 | nonono | Kangaroo (CEOI16_kangaroo) | C++14 | 18 ms | 22996 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>
#define int long long
using namespace std;
const int mod = 1e9 + 7;
const int mxN = 2005;
int n, s, f;
int dp[mxN][mxN];
signed main() {
#define taskname ""
if(fopen(taskname".inp", "r")) {
freopen(taskname".inp", "r", stdin);
freopen(taskname".out", "w", stdout);
}
cin.tie(0)->sync_with_stdio(0);
cin >> n >> s >> f;
dp[1][1] = 1;
for(int i = 1; i < n; i ++) {
int x = (i + 1 >= s) + (i + 1 >= f);
for(int j = 1; j <= i; j ++) {
if(i + 1 == s || i + 1 == f) {
dp[i + 1][j] += dp[i][j];
dp[i + 1][j + 1] += dp[i][j];
continue ;
}
(dp[i + 1][j + 1] += dp[i][j] * (j + 1 - x)) %= mod;
(dp[i + 1][j - 1] += dp[i][j] * (j - 1)) %= mod;
}
}
cout << dp[n][1] << "\n";
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... |