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

#TimeUsernameProblemLanguageResultExecution timeMemory
1118273vjudge1Kangaroo (CEOI16_kangaroo)C++17
100 / 100
13 ms31736 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int sz=2e5+5; const int INF=1e18; const int MOD=1e9+7; int dp[2005][2005]; void solve() { int n,cf,cn,cnt=0; cin>>n>>cf>>cn; dp[1][1]=1; for(int i=1;i<=n;i++) { if(i==cf || i==cn) cnt++; for(int j=1;j<i;j++) { if(i==cf || i==cn) { dp[i][j]+=dp[i-1][j]%MOD; dp[i][j+1]+=dp[i-1][j]%MOD; } else { dp[i][j+1]+=(dp[i-1][j]*(j+1-cnt))%MOD; dp[i][j-1]+=(dp[i-1][j]*(j-1))%MOD; } } } cout<<dp[n][1]; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t=1; //cin>>t; while(t--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...