This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#warning Check FastIO
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <algorithm>
#include <climits>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <fstream>
using namespace std;
#define vll vector<ll>
#define sll set<ll>
#define vstr vector<string>
#define ll long long
#define ld long double
#define supra main
#define pb push_back
#define add insert
#define rall(x) rbegin(x),rend(x)
#define all(x) (x).begin(),(x).end()
#define I ios_base::sync_with_stdio(false);
#define Hear cin.tie(NULL);
#define Shots cout.tie(NULL);
#define Ratatatata
#define bits_on(a) (__builtin_popcountll(a))
#define mx_pw2(a) (__builtin_ctzll(a))
const ll inf=LLONG_MAX;
void pyn(bool a)
{
cout<<(a?"YES":"NO")<<endl;
}
ll powmod(ll a,ll b,ll modulo)
{
if(b==0){
return 1;
}
ll temp=powmod(a,b/2,modulo);
if(b%2==0){
return (temp*temp)%modulo;
}
else{
return (a*((temp*temp)%modulo))%modulo;
}
}
bool Prime(ll n){
for (ll i = 2; i*i <= n; i++)
if (n % i == 0)
return false;
return (n>1);
}
ll ans=0;
// p=0 prev<current
// p=1 prev>current
ll n,cs,cf;
void recur(ll current,bool p,map<ll,bool>& used)
{
bool on=1;
// cout<<"For "<<current<<' '<<p<<endl;
for(auto i:used)
{
// cout<<i.first<<' '<<i.second<<endl;
on&=(i.second);
}
if(on)
{
if(current==cf)
{
ans++;
}
return;
}
for(int i=1;i<=n;i++)
{
if(!used[i])
{
// cout<<"Help "<<i<<' '<<p<<endl;;
if(p and i>current)
{
used[i]=1;
recur(i,!p,used);
used[i]=0;
}
else if(!p and i<current)
{
used[i]=1;
recur(i,!p,used);
used[i]=0;
}
}
}
}
void solve()
{
cin>>n>>cs>>cf;
// ll mod=1e9+7;
map<ll,bool> used;
for(int i=1;i<=n;i++)
{
used[i]=0;
}
used[cs]=1;
for(int i=1;i<=n;i++)
{
if(!used[i])
{
used[i]=1;
recur(i,(cs>i),used);
used[i]=0;
}
}
cout<<ans<<endl;
}
int supra(){
I Hear Shots Ratatatata
// cout<<setprecision(1000);
// freopen("kangaroo.in", "r", stdin);
// freopen("kangaroo.out", "w", stdout);
ll tqwertyuiop=1;
// cin>>tqwertyuiop;
for(int tp=1;tp<=tqwertyuiop;tp++)
{
// cout<<"Case #"<<tp<<": ";
solve();
}
return 0;
}
Compilation message (stderr)
kangaroo.cpp:1:2: warning: #warning Check FastIO [-Wcpp]
1 | #warning Check FastIO
| ^~~~~~~
# | 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... |