Submission #505031

# Submission time Handle Problem Language Result Execution time Memory
505031 2022-01-10T12:20:06 Z lethinh05 Kangaroo (CEOI16_kangaroo) C++11
0 / 100
2 ms 332 KB
#include <bits/stdc++.h>

#define oo 1000000007
#define ll long long
#define ld long double
#define ii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define vi vector<int>
#define vii vector<ii>
#define sz(a) (int)(a.size())
#define pb push_back
#define fto(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define fdto(i, a, b) for (int i = (int)(a); i >= (int)(b); --i)
#define bug(x) "["#x" = "<<(x)<<"] "
#define maxN 2005

using namespace std;

int n, cs, cf;
ll f[maxN][maxN];

int main() {
    #ifndef ONLINE_JUDGE
        freopen("CEOI16_kangaroo.INP", "r", stdin);
        freopen("CEOI16_kangaroo.OUT", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> cs >> cf;

    f[1][1] = 1;
    fto(i, 2, n) {
        fto(j, 1, i) {
            if (i == cs || i == cf) {
                f[i][j] = f[i-1][j-1] + f[i-1][j];
            } else {
                f[i][j] = f[i-1][j-1]*(j - (i > cs) - (i > cf)) + f[i-1][j+1]*j;
            }
        }
    }

    cout << f[n][1] << '\n';
    return 0;
}

Compilation message

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:26:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         freopen("CEOI16_kangaroo.INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:27:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         freopen("CEOI16_kangaroo.OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -