Submission #859461

#TimeUsernameProblemLanguageResultExecution timeMemory
859461GordonRemzi007Kangaroo (CEOI16_kangaroo)C++17
6 / 100
2067 ms348 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long

using namespace std;

bool check(int x, int y, int z) {
    if((x < y && z < y) || (y < x && y < z)) return true;
    return false;
}

int main() {
    ll n, cs, cf, temp = 0;
    bool ok;
    const ll MOD = 1e9+7;
    cin >> n >> cs >> cf;
    vector<int> a(n);
    for(int i = 1; i <= n; i++) a[i-1] = i;
    do {
        ok = true;
        for(int i = 2; i < n; i++) {
            if(!check(a[i-2], a[i-1], a[i])) {
                ok = false;
                break;
            }
        }
        if(a[0] == cs && a[n-1] == cf && ok) temp = (temp+1)%MOD;
    } while(next_permutation(a.begin(), a.end()));
    cout << temp << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...