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

#TimeUsernameProblemLanguageResultExecution timeMemory
116885minhtung0404Kangaroo (CEOI16_kangaroo)C++17
100 / 100
47 ms16060 KiB
//https://oj.uz/problem/view/CEOI16_kangaroo #include<bits/stdc++.h> const int N = 2005; const int mod = 1e9 + 7; using namespace std; int n, dp[N][N], s, e; void add(int&a, int b){ a += b; if (a >= mod) a -= mod; if (a < 0) a += mod; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> s >> e; if (s > e) swap(s, e); dp[0][0] = 1; for (int i = 1; i < n; i++){ for (int j = 1; j <= n; j++){ if (i != s && i != e){ if (i >= e){ add(dp[i][j], 1LL * dp[i-1][j+1] * (j-1) * j % mod); } else{ if (i >= s){ add(dp[i][j], 1LL * dp[i-1][j+1] * j * j % mod); } else{ add(dp[i][j], 1LL * dp[i-1][j+1] * (j+1) * j % mod); } } } else{ if (i == s){ add(dp[i][j], 1LL * dp[i-1][j] * j % mod); } else{ add(dp[i][j], 1LL * dp[i-1][j] * (j-1) % mod); } } add(dp[i][j], dp[i-1][j-1]); } } if (e == n) cout << dp[n-1][1]; else cout << dp[n-1][2]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...