Submission #1176584

#TimeUsernameProblemLanguageResultExecution timeMemory
1176584anha3k25cvpKangaroo (CEOI16_kangaroo)C++20
100 / 100
17 ms31816 KiB
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define dl double
#define st first
#define nd second
#define II pair <int, int>

using namespace std;

const int N = 5 + 1e5;
const ll mod = 7 + 1e9;

int main() {
#define TASKNAME ""
    ios_base :: sync_with_stdio (0);
    cin.tie (0);
    if ( fopen( TASKNAME".inp", "r" ) ) {
        freopen (TASKNAME".inp", "r", stdin);
        freopen (TASKNAME".out", "w", stdout);
    }
    int n, s, t;
    cin >> n >> s >> t;
    vector <vector <ll>> f(n + 1, vector <ll> (n + 2, 0));
    f[1][1] = 1;
    for (int i = 2; i <= n; i ++)
        for (int cnt = 1; cnt <= i; cnt ++)
            if (i == s || i == t)
                f[i][cnt] = (f[i - 1][cnt - 1] + f[i - 1][cnt]) % mod;
            else
                f[i][cnt] = (f[i - 1][cnt - 1] * (cnt - (i > s) - (i > t)) + f[i - 1][cnt + 1] * cnt) % mod;
    cout << f[n][1];
    return 0;
}

Compilation message (stderr)

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