제출 #936450

#제출 시각아이디문제언어결과실행 시간메모리
936450OAleksa캥거루 (CEOI16_kangaroo)C++14
0 / 100
1 ms500 KiB
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define int long long
const int N = 2069;
const int mod = 1e9 + 7;
int dp[N][N][2], n, st, ed;
int add(int x, int y) {
	x += y;
	if (x >= mod)
		x -= mod;
	return x;
}
int sub(int x, int y) {
	x -= y;
	if (x < 0)
		x += mod;
	return x;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt = 1;
  //cin >> tt;
  while (tt--) {
  	cin >> n >> st >> ed;
		dp[st][0][1] = dp[st][0][0] = 1;
		//0-> poslednji potez levo
		//1-> poslednji potez desno
  	for (int j = 1;j < n;j++) {
  		for (int i = 1;i <= n;i++) {
  			if (i == st)
  				continue;
  			for (int k = 1;k < i;k++) {
  				dp[i][j][1] = add(dp[i][j][1], dp[k][j - 1][0]);
  				if (j >= 2 && k != st)
  					dp[i][j][1] = max(0ll, dp[i][j][1] - dp[i][j - 2][1]);
  			}
  			for (int k = i + 1;k <= n;k++) {
  				dp[i][j][0] = add(dp[i][j][0], dp[k][j - 1][1]);
  				if (j >= 2 && k != st)
  					dp[i][j][0] = max(0ll, dp[i][j][0] - dp[i][j - 2][0]);
  			}
  		}
  	}
  	cout << add(dp[ed][n - 1][0], dp[ed][n - 1][1]) << '\n';
  }
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...