This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#include<algorithm>
#include<iostream>
using namespace std;
int main() {
//freopen("kangaroo.in","r",stdin);
//freopen("kangaroo.out","w",stdout);
int n,cs,cf;
cin>>n>>cs>>cf;
int R[n];for (int i=0;i<n;i++) R[i]=i+1;
int M=0;
do {
if ((R[0]==cs)&&(R[n-1]==cf)) {
int sm = 1;
for (int i=0;i<n-2;i++) {
if ((R[i]-R[i+1])*(R[i+1]-R[i+2])>0) sm=0;
}
M+=sm;
}
} while (next_permutation(R,R+n));
cout<<M<<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... |