QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#202889#5532. KangarooCamillus#6 0ms3820kbC++20818b2023-10-06 13:58:222024-07-04 02:16:58

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 02:16:58]
  • 评测
  • 测评结果:6
  • 用时:0ms
  • 内存:3820kb
  • [2023-10-06 13:58:22]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

signed main() {
#ifndef LOCAL
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#else
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, s, f;
    cin >> n >> s >> f;
    s--, f--;
    vector<int> p(n);
    iota(p.begin(), p.end(), 0);
    int cnt = 0;
    do {
        if (p.front() != s || p.back() != f) {
            continue;
        }
        bool ok = true;
        for (int i = 0; i + 2 < n; i++) {
            if (p[i] < p[i + 1]) {
                ok &= p[i + 1] > p[i + 2];
            } else {
                ok &= p[i + 1] < p[i + 2];
            }
        }
        cnt += ok;
    } while (next_permutation(p.begin(), p.end()));

    cout << cnt << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 6
Accepted

Test #1:

score: 6
Accepted
time: 0ms
memory: 3820kb

input:

7 3 6

output:

14

result:

ok 1 number(s): "14"

Subtask #2:

score: 0
Time Limit Exceeded

Dependency #1:

100%
Accepted

Test #2:

score: 0
Time Limit Exceeded

input:

39 36 32

output:


result:


Subtask #3:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%