(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 #316145

#TimeUsernameProblemLanguageResultExecution timeMemory
316145vipghn2003Kangaroo (CEOI16_kangaroo)C++14
100 / 100
37 ms14208 KiB
#include<bits/stdc++.h> using namespace std; const int N=2005; const int mod=1e9+7; int n,cs,cf,dp[N][N]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin>>n>>cs>>cf; if(cs>cf) swap(cs,cf); dp[1][0]=1; for(int i=1;i<=n;i++) { for(int j=0;j<=i;j++) { if(i==cs||i==cf) { dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod; if(j) dp[i+1][j-1]=(dp[i+1][j-1]+1ll*dp[i][j]*j%mod)%mod; continue; } dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%mod; if(j) { dp[i+1][j-1]=(dp[i+1][j-1]+1ll*j*(j-1)%mod*dp[i][j]%mod); if(i>cs) dp[i+1][j-1]=(dp[i+1][j-1]+1ll*dp[i][j]*j%mod)%mod; if(i>cf) dp[i+1][j-1]=(dp[i+1][j-1]+1ll*dp[i][j]*j%mod)%mod; } } } cout<<dp[n][0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...