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

#TimeUsernameProblemLanguageResultExecution timeMemory
1118244vjudge1Kangaroo (CEOI16_kangaroo)C++17
100 / 100
36 ms31836 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mod = 1e9 + 7; int32_t main () { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N, cs, cf, say = 0; cin >> N >> cs >> cf; vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, 0)); dp[0][0] = 1; for (int i = 0;i < N;i ++) { for (int j = 0;j <= i;j ++) { if (i + 1 == cs || i + 1 == cf) { say += (j == 0); dp[i + 1][j + 1] = (dp[i][j] + dp[i + 1][j + 1]) % mod; dp[i + 1][j] = (dp[i][j] + dp[i + 1][j]) % mod; } else { dp[i + 1][j + 1] = (dp[i][j] * max(0, (j + 1 - say)) + dp[i + 1][j + 1]) % mod; if (j - 1 >= 0) dp[i + 1][j - 1] = (dp[i][j] * (j - 1) + dp[i + 1][j - 1]) % mod; } } } // for (int i = 1;i <= N;i ++) { // for (int j = 1;j <= i;j ++) { // // for (int k = 0;k < 3;k ++) { // cout << dp[i][j] << " "; // // } cout << "\n"; // } cout << "\n"; // } cout << "\n"; cout << dp[N][1] << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...