Submission #1177859

#TimeUsernameProblemLanguageResultExecution timeMemory
1177859nguyenkhangninh99캥거루 (CEOI16_kangaroo)C++17
51 / 100
1552 ms68812 KiB

#include<bits/stdc++.h>
using namespace std;

#define int long long

const int mod = 1e9 + 7, maxn = 2e2 + 5;

int dp[2][maxn][maxn][maxn];

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(0); cout.tie(0);
    int n, st, en; cin >> n >> st >> en;

    dp[0][2][2][1] = 1;
    dp[1][2][1][2] = 1;
    for(int k = 3; k <= n; k++){
        for(int i = 1; i <= k; i++){
            for(int j = 1; j <= k; j++){
                if(i == j) continue;
                for(int l = 1; l <= i - 1; l++) (dp[0][k][i][j] += dp[1][k - 1][l][j - (i < j ? 1 : 0)]) %= mod;
                for(int l = i; l <= k - 1; l++) (dp[1][k][i][j] += dp[0][k - 1][l][j - (i < j ? 1 : 0)]) %= mod;
            }
        }
    }

    cout << (dp[0][n][st][en] + dp[1][n][st][en]) % mod;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...