Submission #893606

# Submission time Handle Problem Language Result Execution time Memory
893606 2023-12-27T07:25:39 Z vjudge1 Kangaroo (CEOI16_kangaroo) C++17
0 / 100
2 ms 344 KB

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

const int N = (int)2e5 + 5;
const int MAX = (int)1e9 + 5;
const ll mod = (int)1e9 + 7;
const ll inf = (int)(1e9) + 100;

void setIO(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

void solve() {
     int n;
     cin >> n;
     int cs, cf;
     cin >> cs >> cf;
     vector<int> p;
     for (int i = 1; i <= n; i++) {
        p.pb(i);
     }
     int ans = 0;
     do {
        if (p[0] != cs) continue;
        if (p.back() != cf) continue;
        bool bad = 0;
        for (int i = 1; i < sz(p) - 1; i++) {
            if (!((p[i] > p[i - 1] && p[i] > p[i + 1]) || (p[i] < p[i - 1] && p[i] < p[i + 1]))) {
                bad = 1;
                break;
            }
        }
        ans += !bad;
        ans %= mod;
     } while (next_permutation(all(p)));
     cout << ans;
}


signed main() {
    setIO("kangaroo");
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    while (T--) solve();
    return 0;
}

Compilation message

kangaroo.cpp: In function 'void setIO(std::string)':
kangaroo.cpp:17:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:18:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -