This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main() {
#ifdef ONLINE_JUDGE
ifstream fin("kangaroo.in");
ofstream fout("kangaroo.out");
if (!fin or !fout) {
return 1;
}
#else
istream &fin = cin;
ostream &fout = cout;
#endif
int n, cs, cf, ans = 0;
fin >> n >> cs >> cf;
vector<int> route;
for (int i = 1; i <= n; i++) {
route.push_back(i);
}
do {
if (route.front() != cs or route.back() != cf) {
goto next;
}
for (int i = 1; i < n - 1; i++) {
int prev = route[i - 1], current = route[i], next = route[i + 1];
if ((prev < current and next >= current) or
(current < prev and current >= next)) {
goto next;
}
}
ans++;
next:
continue;
} while (next_permutation(route.begin(), route.end()));
fout << ans << '\n';
#ifdef ONLINE_JUDGE
fout.close();
#endif
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |