Submission #1117691

#TimeUsernameProblemLanguageResultExecution timeMemory
1117691vjudge1Kangaroo (CEOI16_kangaroo)C++17
0 / 100
2 ms14672 KiB
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define inf 0x3F3F3F3F3F3F3F3F

const int MXN = 500 + 5;
const int mod = 1e9 + 7;

int n, cs, cf;
int dp[MXN][MXN][MXN];

int f(int m, int x, int y, int t)
{
  if (x == y)
  {
    if (m == 1) return 1;
    return 0;
  }
  if (dp[m][x][y] != -1) return dp[m][x][y];
  int res = 0;
  for (int i = 1; i <= m; i++)
  {
    if ((i < x) && t == 0) res = (res + f(m - 1, i, (y > x ? y - 1 : y), t ^ 1)) % mod;
    if ((i > x) && t == 1) res = (res + f(m - 1, i - 1, (y > x ? y - 1 : y), t ^ 1)) % mod;
  }
  return dp[m][x][y] = res;
}
void _()
{
  cin >> n >> cs >> cf;
  for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) for (int k = 1; k <= n; k++) dp[i][j][k] = -1;
  cout << (f(n, cs, cf, 0) + f(n, cs, cf, 1)) % mod << '\n';
}

signed main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  // cin >> t;
  while (t--) _();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...