#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define ll long long
#define ull unsigned long long
#define lb lower_bound
#define ub upper_bound
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
int gcd(int a, int b){
return __gcd(a, b);
}
int lcm(int a, int b){
return a / gcd(a, b) * b;
}
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
void solve(){
int n, a, b;
cin >> n >> a >> b;
vector<int> vt;
for (int i = 1; i <= n; i++ ){
if(i != a && i != b)vt.push_back(i);
}
int ans = 0;
do{
bool ok = true;
if(vt[0] < a){
for (int i = 1; i < vt.size(); i++ ){
if(i % 2 != 0){
if(vt[i] <= vt[i - 1]){
ok = false;
break;
}
}
else{
if(vt[i] >= vt[i - 1]){
ok = false;
break;
}
}
}
}
else{
for (int i = 1; i < vt.size(); i++ ){
if(i % 2 == 0){
if(vt[i] <= vt[i - 1]){
ok = false;
break;
}
}
else{
if(vt[i] >= vt[i - 1]){
ok = false;
break;
}
}
}
}
if(ok)ans++;
}while(next_permutation(vt.begin(), vt.end()));
cout << ans << endl;
}
signed main(){
IOS;
int t = 1;
//cin >> t;
while (t--){
solve();
}
}
| # | 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... |