This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// oooo
/*
har chi delet mikhad bebar ~
gitar o ba khodet nabar! ~
;Amoo_Hasan;
*/
#include<bits/stdc++.h>
//#pragma GCC optimize("O3,no-stack-protector,unroll-loops")
//#pragma GCC target("avx2,fma")
using namespace std;
typedef long long ll;
typedef long double ld;
#define Sz(x) int((x).size())
#define All(x) (x).begin(), (x).end()
#define wtf(x) cout<<#x <<" : " <<x <<endl
constexpr ll inf = 1e18, N = 1e6 + 10, mod = 1e9 + 7, pr = 1000696969;
int main() {
ios :: sync_with_stdio(0), cin.tie(0);
int n, s, e; cin >>n >>s >>e;
vector<int> vc;
for(int i = 1; i <= n; i++) vc.push_back(i);
int ans = 0;
do {
if(vc[0] != s || vc.back() != e) continue;
bool t = (vc[1] > vc[0]), ex = 0;
for(int i = 2; i < Sz(vc); i++) {
bool t2 = (vc[i] > vc[i - 1]);
if(t2 == t) {
ex = 1;
break;
}
t = t2;
}
if(!ex) ans++;
} while(next_permutation(All(vc)));
cout<<ans;
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... |