Submission #1267321

#TimeUsernameProblemLanguageResultExecution timeMemory
1267321baotoan655Kangaroo (CEOI16_kangaroo)C++20
100 / 100
14 ms14152 KiB
#include <bits/stdc++.h> #define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } using namespace std; const int MOD = 1e9 + 7; inline int add(int x, int y) { x += y; if(x >= MOD) x -= MOD; return x; } inline int mul(int x, int y) { return (long long) x * y % MOD; } const int N = 2005; int n, a, b; int dp[N][N]; int main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); file("A") else file("task"); cin >> n >> a >> b; dp[1][1] = 1; for(int i = 2; i <= n; ++i) { for(int j = 1; j <= i; ++j) { if(i == a || i == b) { dp[i][j] = add(dp[i - 1][j], dp[i - 1][j - 1]); } else { if(j - (i > a) - (i > b) >= 0) dp[i][j] = add(dp[i][j], mul(dp[i - 1][j - 1], j - (i > a) - (i > b))); dp[i][j] = add(dp[i][j], mul(dp[i - 1][j + 1], j)); } } } cout << dp[n][1] << '\n'; }

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:2:58: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:22:5: note: in expansion of macro 'file'
   22 |     file("A") else file("task");
      |     ^~~~
kangaroo.cpp:2:91: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:22:5: note: in expansion of macro 'file'
   22 |     file("A") else file("task");
      |     ^~~~
kangaroo.cpp:2:58: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:22:20: note: in expansion of macro 'file'
   22 |     file("A") else file("task");
      |                    ^~~~
kangaroo.cpp:2:91: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:22:20: note: in expansion of macro 'file'
   22 |     file("A") else file("task");
      |                    ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...