This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vl vector<ll>
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define pb push_back
#define iospeed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main()
{
iospeed
ll n, cs, cf, i;
cin >> n >> cs >> cf;
vl v;
for(i = 1; i <= n; i++)
v.pb(i);
ll res = 0;
do{
if(v[0] != cs || v.back() != cf)
continue;
ll lst = 1;
if(v[1] < v[0])
lst = 0;
bool ok = true;
for(i = 2; i < n; i++)
{
if((v[i] > v[i-1] && lst) || (v[i] < v[i-1] && !lst)){
ok = false;
break;
}
lst = 1 - lst;
}
if(ok)
res++;
}while(next_permutation(all(v)));
cout << res << "\n";
}
# | 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... |