#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAX = 1e5 + 10;
vector<int> vt[MAX];
void solve() {
int n, a, b;
cin >> n >> a >> b;
vector<int> e;
for(int i = 1; i <= n; i++) {
if(i != a && i != b) {
e.push_back(i);
}
}
int ans = 0;
do{
deque<int> vt;
vt.push_back(a);
for(int i = 0; i < e.size(); i++) {
vt.push_back(e[i]);
}
vt.push_back(b);
int k = vt.size();
int say = 0;
vt.push_back(0);
for(int i = 0; i < k; i += 2) {
if(vt[i + 1] <= vt[i]) {
say++;
}
}
if(say == vt.size() / 2) {
ans++;
}
else {
vt.pop_back();
say = 0;
vt.push_back(n);
for(int i = 0; i < k; i += 2) {
if(vt[i + 1] >= vt[i]) {
say++;
}
}
if(say == vt.size() / 2) {
ans++;
}
}
}while(next_permutation(e.begin(), e.end()));
cout << ans << endl;
}
signed main() {
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... |