Submission #1293859

#TimeUsernameProblemLanguageResultExecution timeMemory
1293859AzeTurk810Kangaroo (CEOI16_kangaroo)C++20
51 / 100
1266 ms34112 KiB
/*
Telebe of Adicto && Mamedov yani AzeTurk810
I see humans but no humanity
*/
#include <iostream>

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

using ll = long long;
using namespace std;

#define ln '\n'
#define INFi 1e9
#define INFll 1e18

constexpr int up = 202 , MOD = 1e9 + 7;

int dp[2][up][up][up];

void solve() {
    int n ,cs , cf;
    cin >> n >> cs >> cf;
    dp[0][2][1][2] = 1;
    dp[1][2][2][1] = 1;
    for(int l = 3;l <= n;l++) {
        for(int s = 1;s <= l;s ++) {
            for(int f = 1;f <= l; f++) {
                if(s == f) 
                    continue;
                for(int k = s;k < l;k++) {
                    dp[0][l][s][f] += dp[1][l - 1][k][f - (f > s)];
                    dp[0][l][s][f] %= MOD;
                }
                for(int k = 1;k < s;k++) {
                    dp[1][l][s][f] += dp[0][l - 1][k][f - (f > s)];
                    dp[1][l][s][f] %= MOD;
                }
            }
        }
    }
    cout << (dp[0][n][cs][cf] + dp[1][n][cs][cf]) % MOD << ln;
}

// Attack on titan<3

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int t = 1;
//      cin >> t;
    for(int cases = 0 ; cases < t;cases ++) {
        solve();
    }
}
// Just Imaginary
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...