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

#TimeUsernameProblemLanguageResultExecution timeMemory
490700mihhKangaroo (CEOI16_kangaroo)C++17
0 / 100
0 ms204 KiB
#include <bits/stdc++.h> using namespace std; /* tutorial : https://codeforces.com/blog/entry/47764 (ctrl f it) N celule 1->n cangur celula cs sare in alta celula se opreste in celula cf n-1 sarituri arbritare schimba directia in care sare */ int n, cf, cs; const int MOD=1e9+7, N=2e3+1; int add(int x, int y){ return (x+y)%MOD; } int mul(int x, int y){ return (1LL*x*y)%MOD; } int dp[N][N]; int main(){ ifstream fin("kangaroo.in"); ofstream fout("kangaroo.out"); fin>>n>>cs>>cf; fin.close(); dp[0][0]=1; for(int i=1; i<=n; ++i){ for(int c=1;c<=i;++c){ if(!(i==cs or i==cf)){ dp[i][c]=add( mul(dp[i-1][c-1], c-(i>cs)-(i>cf)), mul(dp[i-1][c+1], c) ); }else{ dp[i][c]=add(dp[i-1][c-1],dp[i-1][c]); } } } int ans=dp[n][1]; fout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...