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

#TimeUsernameProblemLanguageResultExecution timeMemory
204019mahmoudbadawyKangaroo (CEOI16_kangaroo)C++17
100 / 100
26 ms23032 KiB
#include <bits/stdc++.h> using namespace std; const int N=2005,MOD=1e9+7; long long mem[N][N]; int n,a,b; int main() { cin >> n >> a >> b; mem[1][1]=1; for(int i=2;i<=n;i++) { for(int j=1;j<=i;j++) { if(i==a||i==b) { mem[i][j]=mem[i-1][j]+mem[i-1][j-1]; if(mem[i][j]>=MOD) mem[i][j]-=MOD; continue; } mem[i][j]=mem[i-1][j-1]*(j-((i>a)+(i>b))); // add a new component mem[i][j]%=MOD; mem[i][j]+=mem[i-1][j+1]*j; // combine two existing components; mem[i][j]%=MOD; } } cout << mem[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...