Submission #1146922

#TimeUsernameProblemLanguageResultExecution timeMemory
1146922iahKangaroo (CEOI16_kangaroo)C++20
0 / 100
0 ms324 KiB
#include<bits/stdc++.h> using namespace std; #define NAME "" #define ll long long #define pii pair < int , int > #define fi first #define se second #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i ++) #define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; i --) #define REP(i, n) for (int i = 0, _n = (n); i < _n; i ++) #define bit(x, i) (((x) >> (i)) & 1ll) #define mask(x) (1ll << (x)) #define mem(f, x) memset(f, x, sizeof(f)) #define sz(x) (int32_t) (x.size()) const int nmax = 2000; const int mod = 1e9 + 7; int dp[nmax + 7][nmax + 7]; void add(int &x, int y) { x += y; if (x >= mod) { x -= mod; } } signed main() { for(string s: {NAME, ""}) { if (fopen((s + ".inp").c_str(), "r")) { freopen((s + ".inp").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); break; } } cin.tie(0)->sync_with_stdio(0); int n, cs, cf; cin >> n >> cs >> cf; dp[1][1] = 1; FOR(i, 2, n) { FOR(j, 1, i) { dp[i % 2][j] = 0; } FOR(j, 1, i - 1) { add(dp[i % 2][j + 1], dp[1 - i % 2][j]); if (i == cs || i == cf) { add(dp[i % 2][j], dp[1 - i % 2][j]); } else if (j - 1 > 0) { add(dp[i % 2][j - 1], dp[1 - i % 2][j]); } } // cout << i << ":\n"; // FOR(j, 1, i) { // cout << j << " " << dp[i % 2][j] << "\n"; // } } cout << dp[n % 2][1]; return 0; }

Compilation message (stderr)

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