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

#TimeUsernameProblemLanguageResultExecution timeMemory
318214a14789654Kangaroo (CEOI16_kangaroo)C++17
100 / 100
32 ms14220 KiB
///https://oj.uz/problem/view/CEOI16_kangaroo #include <bits/stdc++.h> using namespace std; const int MAXN = 2007, MOD = 1e9 + 7; int cs, cf, n, f[MAXN][MAXN]; void add(int &a, int b) { a += b; if (a >= MOD) a -= MOD; } int main() { if (fopen("tst.inp", "r")) { freopen("tst.inp", "r", stdin); freopen("tst.out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); cin >> n >> cs >> cf; if (cs > cf) swap(cs, cf); f[1][0] = 1; for (int i = 1; i <= n; ++i) for (int j = 0; j <= i; ++j) if (i != cs && i != cf) { if (i < n && j) add(f[i + 1][j - 1], 1LL * f[i][j] * j * (j - 1) % MOD); if (i < n && j < n) add(f[i + 1][j + 1], f[i][j]); if (i > cs && i < n && j) add(f[i + 1][j - 1], 1LL * f[i][j] * j % MOD); if (i > cf && i < n && j) add(f[i + 1][j - 1], 1LL * f[i][j] * j % MOD); } else { add(f[i + 1][j], f[i][j]); if (j) add(f[i + 1][j - 1], 1LL * f[i][j] * j % MOD); } cout << f[n][0]; return 0; }

Compilation message (stderr)

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