제출 #1134281

#제출 시각아이디문제언어결과실행 시간메모리
1134281irmuun캥거루 (CEOI16_kangaroo)C++17
51 / 100
1473 ms589824 KiB
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

const ll mod=1e9+7;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n,st,en;
    cin>>n>>st>>en;
    //if(st>en) swap(st,en);
    ll dp[2][n+5][n+5][n+5];
    memset(dp,0,sizeof dp);
    dp[0][1][1][1]=1;
    dp[1][1][1][1]=1;
    dp[0][2][2][1]=1;
    dp[1][2][1][2]=1;
    //0-dec 1-inc
    for(ll k=3;k<=n;k++){
        for(ll i=1;i<=k;i++){
            for(ll j=1;j<=k;j++){
                if(i==j) continue;
                for(ll l=1;l<=i-1;l++){
                    dp[0][k][i][j]+=dp[1][k-1][l][j-(i<j?1:0)];
                    dp[0][k][i][j]%=mod;
                }
                for(ll l=i;l<k;l++){
                    dp[1][k][i][j]+=dp[0][k-1][l][j-(i<j?1:0)];
                    dp[1][k][i][j]%=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...