Submission #1294043

#TimeUsernameProblemLanguageResultExecution timeMemory
1294043cavid_07Kangaroo (CEOI16_kangaroo)C++20
6 / 100
2095 ms572 KiB
#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define pb push_back
#define int long long
#define no cout << "No" << '\n'
#define yes cout << "Yes" << '\n'
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define inp(v) for (auto &a : v) cin >> a;
#define out(v) for (auto &a : v) cout << a << ' ';

void solve() {
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> vt(n);
    for(int i = 1; i <= n; i++){
        vt[i - 1] = i;
    }
    int mod = 1e9 + 7;
    int ans = 0;
    do {
        bool ok = true;
        for (int i = 1; i < n - 1; i++) {
            if (!(vt[i] > vt[i - 1] and vt[i] > vt[i + 1] or vt[i] < vt[i - 1] and vt[i] < vt[i + 1])){
                ok = false;
            }
        }
        if (vt[0] != a or vt[n - 1] != b) {
            ok = false;
        }
        if (ok) ans++;
    }while(next_permutation(all(vt)));
    cout << ans << '\n';
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t = 1;
    //cin >> t;
    while(t--) solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...