# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
505031 | lethinh05 | Kangaroo (CEOI16_kangaroo) | C++11 | 2 ms | 332 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 oo 1000000007
#define ll long long
#define ld long double
#define ii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define vi vector<int>
#define vii vector<ii>
#define sz(a) (int)(a.size())
#define pb push_back
#define fto(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define fdto(i, a, b) for (int i = (int)(a); i >= (int)(b); --i)
#define bug(x) "["#x" = "<<(x)<<"] "
#define maxN 2005
using namespace std;
int n, cs, cf;
ll f[maxN][maxN];
int main() {
#ifndef ONLINE_JUDGE
freopen("CEOI16_kangaroo.INP", "r", stdin);
freopen("CEOI16_kangaroo.OUT", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> cs >> cf;
f[1][1] = 1;
fto(i, 2, n) {
fto(j, 1, i) {
if (i == cs || i == cf) {
f[i][j] = f[i-1][j-1] + f[i-1][j];
} else {
f[i][j] = f[i-1][j-1]*(j - (i > cs) - (i > cf)) + f[i-1][j+1]*j;
}
}
}
cout << f[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... |