Submission #222691

#TimeUsernameProblemLanguageResultExecution timeMemory
222691MinnakhmetovKangaroo (CEOI16_kangaroo)C++14
36 / 100
2078 ms31004 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 205, MOD = 1e9 + 7;
int dp[N][N][N][2];

void add(int &a, int b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, cs, cf;
    cin >> n >> cs >> cf;

    cs--, cf--;

    dp[2][0][1][1]++;
    dp[2][1][0][0]++;

    for (int i = 3; i <= n; i++) {
    	for (int j = 0; j < i; j++) {
    		for (int k = 0; k < i; k++) {
    			if (j != k) {
	    			for (int h = 0; h < j; h++) {
	    				if (h != k)
	    					add(dp[i][j][k][0], dp[i - 1][h][k - (k > j)][1]);
	    			}
	    			for (int h = j + 1; h < n; h++) {
	    				if (h != k)
	    					add(dp[i][j][k][1], dp[i - 1][h - 1][k - (k > j)][0]);
	    			}
    			}
    		}
    	}
    }

    int ans = (dp[n][cs][cf][0] + dp[n][cs][cf][1]) % MOD;

    cout << ans;

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