Submission #1118212

#TimeUsernameProblemLanguageResultExecution timeMemory
1118212vjudge1Kangaroo (CEOI16_kangaroo)C++17
100 / 100
41 ms31772 KiB
#pragma GCC optimize("O3") #include<bits/stdc++.h> #define ll long long #define endl "\n" #define AI ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; ll dp[2001][2001]; int main() { AI //freopen("kangaroo.in", "r", stdin); // freopen("kangaroo.out", "w", stdout); ll n,cs,cf,i,j,f=0,mod=1e9+7; cin>>n>>cs>>cf; dp[0][0]=1; for(i=1;i<=n;i++) { if(i==cf or i==cs) f++; for(j=1;j<=n;j++) { if(i==cf or i==cs) { dp[i][j]+=dp[i-1][j]; dp[i][j]%=mod; dp[i][j]+=dp[i-1][j-1]; dp[i][j]%=mod; } else { dp[i][j]+=dp[i-1][j-1]*(j-f); dp[i][j]%=mod; dp[i][j]+=dp[i-1][j+1]*j; dp[i][j]%=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...