답안 #936450

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
936450 2024-03-01T20:07:38 Z OAleksa 캥거루 (CEOI16_kangaroo) C++14
0 / 100
1 ms 500 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 500 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 500 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 500 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 500 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -