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() {
int N, cs, cf;
cin >> N >> cs >> cf;
vector<int> a(N);
iota(begin(a),end(a),1);
int ans = 0;
do {
if (a[0] == cs && a[N - 1] == cf) {
int f = a[1] > a[0];
int r = 1;
for (int i = 2; i < N; i ++) {
int d = a[i] > a[i - 1];
if (f == d) {
r = 0;
}
f = d;
}
if (r) {
ans ++;
}
}
} while (next_permutation(begin(a),end(a)));
cout << ans << endl;
}
# | 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... |