(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #225470

#TimeUsernameProblemLanguageResultExecution timeMemory
225470brcodeKangaroo (CEOI16_kangaroo)C++14
100 / 100
38 ms39680 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; const int MAXN = 5e3+5; const long long MOD = 1e9+7; long long dp[MAXN][MAXN]; int n,a,b; int main(){ cin>>n>>a>>b; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(i==1 && j==1){ dp[i][j] = 1; continue; } if(i==a||i==b){ dp[i][j] = dp[i-1][j-1]+dp[i-1][j]; dp[i][j]%=MOD; }else{ dp[i][j] = dp[i-1][j+1]*j; dp[i][j]%=MOD; dp[i][j]+=dp[i-1][j-1]*(j-(i>a)-(i>b)); dp[i][j]%=MOD; } } } cout<<dp[n][1]<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...