Submission #830941

#TimeUsernameProblemLanguageResultExecution timeMemory
83094112345678Kangaroo (CEOI16_kangaroo)C++17
0 / 100
0 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int nx=2e3+5, mod=1e9+7; ll dp[nx][nx], n, s, e, k=2; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>s>>e; dp[1][1]=1; for (ll i=1; i<=n; i++) { if (i==s||i==e) { for (int j=1; j<i; j++) { dp[i][j+1]=(dp[i][j+1]+dp[i-1][j])%mod; dp[i][j]=(dp[i][j]+dp[i-1][j])%mod; } k--; continue; } for (ll j=1; j<i; j++) { dp[i][j+1]=(dp[i][j+1]+dp[i-1][j]*(j+1-k-2))%mod; dp[i][j-1]=(dp[i][j-1]+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...