제출 #813182

#제출 시각아이디문제언어결과실행 시간메모리
813182ttamx캥거루 (CEOI16_kangaroo)C++14
100 / 100
15 ms14100 KiB
#include<bits/stdc++.h> using namespace std; const int N=2005; const int mod=1e9+7; int n,s,e; int dp[N][N]; int main(){ cin.tie(nullptr)->sync_with_stdio(false); cin >> n >> s >> e; dp[1][1]=1; int cnt=2; for(int i=1;i<=n;i++){ if(i==s||i==e){ for(int j=1;j<i;j++){ dp[i][j+1]+=dp[i-1][j]; if(dp[i][j+1]>=mod)dp[i][j+1]-=mod; dp[i][j]+=dp[i-1][j]; if(dp[i][j]>=mod)dp[i][j]-=mod; } cnt--; continue; } for(int j=1;j<i;j++){ dp[i][j+1]=(dp[i][j+1]+1ll*dp[i-1][j]*(cnt+j-1))%mod; dp[i][j-1]=(dp[i][j-1]+1ll*dp[i-1][j]*(j-1))%mod; } } cout << dp[n][1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...