제출 #261209

#제출 시각아이디문제언어결과실행 시간메모리
261209super_j6Kangaroo (CEOI16_kangaroo)C++14
36 / 100
2099 ms237816 KiB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second

const int mod = 1000000007;
const int mxn = 2001;
int n, x, y;
map<int, int> dp[mxn][mxn];

int sol(int n, int x, int y){
 	if(dp[n][x].count(y)) return dp[n][x][y];
	int ret = 0;
	for(int i = (n & 1) * (x + 1); i < (n & 1 ? n : x); i++){
		if(i != y) (ret += sol(n - 1, i - (n & 1), y - (x < y))) %= mod;
	}
	return dp[n][x][y] = ret;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	for(int i = 0; i < 2; i++)
	for(int j = 0; j < 2; j++){
		dp[2][i][j] = 0;
	}
	dp[2][1][0] = 1;
	
	cin >> n >> x >> y;
	x--, y--;
	
	int ret = (sol(n, x, y) + sol(n, n - x - 1, n - y - 1)) % mod;
	
	cout << ret << endl;

	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...