Submission #859461

# Submission time Handle Problem Language Result Execution time Memory
859461 2023-10-10T07:39:20 Z GordonRemzi007 Kangaroo (CEOI16_kangaroo) C++17
6 / 100
2000 ms 348 KB
#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 time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Execution timed out 2067 ms 348 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Execution timed out 2067 ms 348 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Execution timed out 2067 ms 348 KB Time limit exceeded
4 Halted 0 ms 0 KB -