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

#TimeUsernameProblemLanguageResultExecution timeMemory
1118303vjudge1Kangaroo (CEOI16_kangaroo)C++17
100 / 100
35 ms23132 KiB
#include "bits/stdc++.h" using ll = long long; using namespace std; const int md = 1000000007; const int mxN = 2003; ll dp[mxN][mxN]; int main() { int N, cs, cf; cin >> N >> cs >> cf; dp[1][1] = 1; int fixed = 0; for (int i = 1; i <= N; i ++) { if (i == cs) { fixed ++; } if (i == cf) { fixed ++; } if (i ^ 1) { for (int j = 1; j <= i; j ++) { if (i ^ cs && i ^ cf) { (dp[i][j] += dp[i - 1][j - 1] * (j - fixed) % md) %= md; (dp[i][j] += dp[i - 1][j + 1] * j % md) %= md; } else { (dp[i][j] += dp[i - 1][j - 1]) %= md; (dp[i][j] += dp[i - 1][j]) %= md; } } } } cout << dp[N][1] << endl; } /* 1 36275 4 3 1 2 yeni component elementi kimese birlesdirirsen ya da iki componenti merge edirsen */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...