# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
96885 | Kastanda | Kangaroo (CEOI16_kangaroo) | C++11 | 2037 ms | 1096 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.
// I do it for the glory
#include<bits/stdc++.h>
using namespace std;
const int N = 205, Mod = 1e9 + 7;
int dp[2][N][N][2];
inline int MOD(int a)
{
if (a >= Mod)
a -= Mod;
if (a < 0)
a += Mod;
return a;
}
int main()
{
int n, s, f;
scanf("%d%d%d", &n, &s, &f);
dp[0][1][2][0] = dp[0][2][1][1] = 1;
for (int i = 3; i <= n; i ++)
{
bool w = i & 1;
for (int st = 1; st <= i; st ++)
for (int fn = 1; fn <= i; fn ++)
if (fn != st)
{
dp[w][st][fn][0] = dp[w][st][fn][1] = 0;
// 0 :
for (int h = st + 1; h <= i; h ++)
if (h != fn)
dp[w][st][fn][0] = MOD(dp[!w][h-1][fn - (st < fn)][1] + dp[w][st][fn][0]);
// 1 :
for (int h = 1; h < st; h ++)
if (h != fn)
dp[w][st][fn][1] = MOD(dp[!w][h][fn - (st < fn)][0] + dp[w][st][fn][1]);
}
}
return !printf("%d\n", MOD(dp[n & 1][s][f][0] + dp[n & 1][s][f][1]));
}
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... |