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

#TimeUsernameProblemLanguageResultExecution timeMemory
1118247vjudge1Kangaroo (CEOI16_kangaroo)C++17
100 / 100
36 ms23124 KiB
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define int long long using namespace std; const int sz = 2e3 + 4, mod = 1e9 + 7; int n, s, f, dp[sz][sz]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> s >> f; int fixed = 0; dp[1][1] = 1; for(int i = 1; i <= n; i++) { if(i == s || i == f) fixed++; for(int j = 1; j <= i; j++) { if(i == s || i == f) { dp[i][j] += dp[i - 1][j - 1]; dp[i][j] %= mod; dp[i][j] += dp[i - 1][j]; dp[i][j] %= mod; } else { dp[i][j] += dp[i - 1][j - 1] * (j - fixed) % mod; dp[i][j] %= mod; dp[i][j] += dp[i - 1][j + 1] * j % mod; dp[i][j] %= mod; } } } cout << dp[n][1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...