QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#202889 | #5532. Kangaroo | Camillus# | 6 | 0ms | 3820kb | C++20 | 818b | 2023-10-06 13:58:22 | 2024-07-04 02:16:58 |
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%