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

#TimeUsernameProblemLanguageResultExecution timeMemory
474834ntabc05101Kangaroo (CEOI16_kangaroo)C++14
100 / 100
40 ms15948 KiB
#include<bits/stdc++.h> using namespace std; #define taskname "kangaroo" const int mxN = 2000; const int mod = 1e9 + 7; int n, cs, cf; int dp[mxN + 5][mxN + 5]; int main() { if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } cin.tie(0)->sync_with_stdio(0); cin >> n >> cs >> cf; dp[1][1] = 1; for (int i = 2; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i == cs || i == cf) { dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % mod; } else { dp[i][j] = 1ll * dp[i - 1][j + 1] * j % mod; (dp[i][j] += 1ll * dp[i - 1][j - 1] * (j - (i > cs) - (i > cf)) % mod) %= mod; } } } cout << dp[n][1] << "\n"; return 0; }

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:14:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     freopen(taskname".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen(taskname".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...