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

#TimeUsernameProblemLanguageResultExecution timeMemory
469744TheScrasseKangaroo (CEOI16_kangaroo)C++17
100 / 100
41 ms31772 KiB
#include <bits/stdc++.h> using namespace std; #define nl "\n" #define nf endl #define ll long long #define pb push_back #define _ << ' ' << #define INF (ll)1e18 #define mod 1000000007 #define maxn 2010 ll i, i1, j, k, k1, t, n, m, res, flag[10], a, b; ll st, nd, dp[maxn][maxn]; int main() { ios::sync_with_stdio(0); cin.tie(0); #if !ONLINE_JUDGE && !EVAL ifstream cin("input.txt"); ofstream cout("output.txt"); #endif cin >> n >> st >> nd; if (n == 2) { cout << 1 << nl; return 0; } dp[1][1] = 1; for (i = 1; i <= n; i++) { if (i == st || i == nd) k++; if (i == 1) continue; for (j = 0; j <= n; j++) { if (i == st || i == nd) { if (j >= 1) dp[i][j] += dp[i - 1][j - 1]; if (st + nd != 3) dp[i][j] += dp[i - 1][j]; } else { if (j >= 1) dp[i][j] += (max((ll)0, j - k) * dp[i - 1][j - 1]); dp[i][j] += (j * dp[i - 1][j + 1]); } dp[i][j] %= mod; } } /* for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { cout << dp[i][j] << ' '; } cout << nl; } */ cout << dp[n][1] << nl; 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...