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

#TimeUsernameProblemLanguageResultExecution timeMemory
333748phathnvKangaroo (CEOI16_kangaroo)C++11
100 / 100
18 ms14188 KiB
#include <bits/stdc++.h> #define mp make_pair #define X first #define Y second #define taskname "kangaroo" using namespace std; typedef long long ll; typedef pair <int, int> ii; const int N = 2001; const int MOD = 1e9 + 7; int sum(int a, int b){ a += b; a -= (a >= MOD) * MOD; return a; } int mul(int a, int b){ return (ll) a * b % MOD; } int n, dp[N][N], cs, cf; void readInput(){ cin >> n >> cs >> cf; } void solve(){ dp[0][0] = 1; int fixed = 0; for(int i = 1; i <= n; i++){ for(int j = 1; j <= i; j++) if (i == cs || i == cf) dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1]) % MOD; else dp[i][j] = sum(mul(dp[i - 1][j + 1], j), mul(dp[i - 1][j - 1], j - fixed)); fixed += (i == cs || i == cf); } cout << dp[n][1]; } int main(){ if (fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); readInput(); solve(); return 0; }

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:48:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   48 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:49:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   49 |         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...