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

#TimeUsernameProblemLanguageResultExecution timeMemory
158089solimm4sksKangaroo (CEOI16_kangaroo)C++14
100 / 100
36 ms16120 KiB
#include <bits/stdc++.h> using namespace std; int dp[2005][2005]; const int MOD = 1e9 + 7; int main() { int n, cs, cf; cin >> n >> cs >> cf; dp[0][0] = 1; for(int i = 1; i <= n; ++i){ for(int j = 1; j <= n; ++j){ if(i == cs || i == cf){ ///must put this at beggining or end dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1]; ///(will link/wont link chain) dp[i][j] %= MOD; }else{ dp[i][j] = (1LL * dp[i - 1][j + 1] * j) % MOD + (1LL * dp[i - 1][j - 1] * (j - (i > cs) - (i > cf))) % MOD; ///if i > cs I cant put it before cs, if i > cf then I cant put it after it dp[i][j] %= MOD; } } } cout << dp[n][1] << "\n"; return 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...