Submission #1005044

# Submission time Handle Problem Language Result Execution time Memory
1005044 2024-06-22T06:35:35 Z SulA Kangaroo (CEOI16_kangaroo) C++17
6 / 100
2000 ms 348 KB
#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

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 time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Execution timed out 2065 ms 348 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Execution timed out 2065 ms 348 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Execution timed out 2065 ms 348 KB Time limit exceeded
4 Halted 0 ms 0 KB -