Submission #543115

#TimeUsernameProblemLanguageResultExecution timeMemory
543115iulia13Kangaroo (CEOI16_kangaroo)C++14
0 / 100
17 ms16360 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1005; #define ll long long const ll mod = 1e9 + 7; void sum(ll &a, ll b) { a += b; if (a >= mod) a -= mod; } ll dp[N][N]; int main() { freopen ("kangaroo.in", "r", stdin); freopen ("kangaroo.out", "w", stdout); ll n, cs, cf; cin >> n >> cs >> cf; dp[1][1] = 1; for (ll i = 1; i <= n; i++) for (ll j = 1; j <= n; j++) { if (i == cs || i == cf) { sum(dp[i][j], dp[i - 1][j - 1]); sum(dp[i][j], dp[i - 1][j]); continue; } sum(dp[i][j], dp[i - 1][j + 1] * j % mod); sum(dp[i][j], (dp[i - 1][j - 1] * ((j - 2) + (i < cs) + (i < cf))) % mod); } cout << dp[n][1]; return 0; }

Compilation message (stderr)

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