제출 #492877

#제출 시각아이디문제언어결과실행 시간메모리
492877czhang2718캥거루 (CEOI16_kangaroo)C++17
6 / 100
1 ms204 KiB
#include "bits/stdc++.h" using namespace std; const int MOD=1e9+7; int n, s, e; int dp[2001], dp2[2001]; int mult(int a, int b){ return ((long long )a*b)%MOD; } int add(int &a, int b){ a+=b; if(a>=MOD) a-=MOD; return a; } int main(){ cin.tie(0)->sync_with_stdio(0); // freopen("kangaroo.in", "r", stdin); // freopen("kangaroo.out", "w", stdout); cin >> n >> s >> e; dp[0]=1; for(int i=1; i<=n; i++){ for(int j=0; j<i; j++){ if(!dp[j]) continue; if(i==s || i==e){ add(dp2[j+1], dp[j]); if(j) add(dp2[j], dp[j]); continue; } add(dp2[j+1], mult(dp[j], (j+1-(i>s)-(i>e)))); if(j>=2) dp2[j-1]+=mult(dp[j], j-1); } for(int j=0; j<=i; j++){ dp[j]=dp2[j]; dp2[j]=0; } } cout << dp[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...