Submission #1005044

#TimeUsernameProblemLanguageResultExecution timeMemory
1005044SulAKangaroo (CEOI16_kangaroo)C++17
6 / 100
2065 ms348 KiB
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int n,cs,cf; cin >> n >> cs >> cf;
    vector<int> p;
    for (int i = 1; i <= n; i++) {
        p.push_back(i);
    }

    long long cnt = 0;
    do {
        bool isGood = p.front() == cs && p.back() == cf;
        if (!isGood) continue;
        for (int i = 1; i < n-1; i++) {
            isGood &= p[i+1] > p[i] != p[i] > p[i-1];
        }
        cnt += isGood;
    } while (next_permutation(p.begin(), p.end()));
    cout << cnt;
}

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:20:30: warning: suggest parentheses around comparison in operand of '!=' [-Wparentheses]
   20 |             isGood &= p[i+1] > p[i] != p[i] > p[i-1];
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...