# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
543115 | iulia13 | Kangaroo (CEOI16_kangaroo) | C++14 | 17 ms | 16360 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 = 1005;
#define ll long long
const ll mod = 1e9 + 7;
void sum(ll &a, ll b)
{
a += b;
if (a >= mod)
a -= mod;
}
ll dp[N][N];
int main()
{
freopen ("kangaroo.in", "r", stdin);
freopen ("kangaroo.out", "w", stdout);
ll n, cs, cf;
cin >> n >> cs >> cf;
dp[1][1] = 1;
for (ll i = 1; i <= n; i++)
for (ll j = 1; j <= n; j++)
{
if (i == cs || i == cf)
{
sum(dp[i][j], dp[i - 1][j - 1]);
sum(dp[i][j], dp[i - 1][j]);
continue;
}
sum(dp[i][j], dp[i - 1][j + 1] * j % mod);
sum(dp[i][j], (dp[i - 1][j - 1] * ((j - 2) + (i < cs) + (i < cf))) % mod);
}
cout << 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... |