답안 #1005044

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005044 2024-06-22T06:35:35 Z SulA 캥거루 (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];
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -