#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
int n , cs , cf;
cin >> n >> cs >> cf;
int ans = 0 ;
vector<int>v(n);
for(int i = 0 ; i < n ; i++){
v[i] = i + 1;
}
do{
if(v[0] != cs || v[n - 1] != cf){
continue;
}
bool ok = true;
for(int i = 1 ; i < n - 1 ; i++){
int last = v[i - 1];
int now = v[i];
int next = v[i + 1];
if(last < now && next >= now){
ok = false;
break;
}
if(last > now && next <= now){
ok = false;
break;
}
}
if(ok){
ans++;
}
}
while(next_permutation(v.begin() , v.end()));{
cout << ans << endl;
}
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... |