#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
#define vint vector<int>
#define vpint vector<pint>
#define vll vector<ll>
#define vpll vector<pll>
#define fast_cin() \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL)
#define MOD %= 1000000007
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
using Tree =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// are you certain that you have a clear idea of your code in your head?
// don't rush to the computer it'll only make it worse, it never works
// if this is the first time reading this you definitely need to go back and
// think about the implementation
void solve() {
int n; cin>>n;
int cn,cf; cin>>cn>>cf;
cn--; cf--;
int a[n]; for(int i = 0; i<n; i++) a[i] = i;
int cnt = 0;
do{
if(a[0]!=cn||a[n-1]!=cf) goto fail;
for(int i = 0; i<n-2; i++){
if(a[i]>a[i+1]&&a[i+1]>a[i+2]) goto fail;
if(a[i]<a[i+1]&&a[i+1]<a[i+2]) goto fail;
}
cnt++;
fail:
continue;
}while(next_permutation(a,a+n));
cout<<cnt<<'\n';
}
int main() {
fast_cin();
#ifdef MYPC
freopen("input.in", "r", stdin);
#endif
int t;
t = 1;
while (t--) {
solve();
}
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... |