# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1118229 | vjudge1 | Kangaroo (CEOI16_kangaroo) | C++17 | 39 ms | 31832 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;
#define int long long
#define inf 0x3F3F3F3F3F3F3F3F
const int MXN = 2e3 + 5;
const int mod = 1e9 + 7;
int dp[MXN][MXN];
void _()
{
int n, x, y;
cin >> n >> x >> y;
dp[0][0] = 1;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
if (i == x || i == y)
{
dp[i][j] += dp[i - 1][j - 1];
dp[i][j] += dp[i - 1][j];
dp[i][j] % mod;
}
else
{
int cnt = j;
dp[i][j] += (dp[i - 1][j + 1] * cnt) % mod;
cnt = j - (i - 1 >= x) - (i - 1 >= y);
dp[i][j] += (dp[i - 1][j - 1] * cnt) % mod;
dp[i][j] % mod;
}
}
}
cout << dp[n][1] << '\n';
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
// cin >> t;
while (t--) _();
}
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... |