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>
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
using namespace std;
int main(){
int n,s,f;
cin>>n>>s>>f;
vector<int> a;
for(int i=1;i<=n;i++) a.push_back(i);
int answer=0;
do{
if(a[0]==s&&a.back()==f){
bool yes=1;
for(int i=1;i+1<n;i++)
if((a[i]>a[i-1]&&a[i]>a[i+1])||(a[i]<a[i-1]&&a[i]<a[i+1]))
yes=1;
answer+=yes;
}
}while(next_permutation(a.begin(),a.end()));
cout<<answer;
return 0;
}
# | 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... |