# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1117810 | vjudge1 | 캥거루 (CEOI16_kangaroo) | C++17 | 2075 ms | 336 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define endl '\n'
#define pb push_back
#define speedyboy ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin() , x.end()
#define F first
#define S second
#define pll pair<ll , ll>
#define pss pair<string , string>
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
const ll sz = 10 , INF = 1e18 , MOD = 998244353;
ll a[sz];
void open(){
freopen("kangaroo.in" , "r" , stdin);
freopen("kangaroo.out" , "w" , stdout);
}
ll i , j , k;
void solve(){
ll n , l , r , ans = 0;
cin >> n >> l >> r;
for(i = 1 ; i <= n ; i++){
a[i] = i;
}
do{
if(a[1] == l && a[n] == r){
bool ok = true;
ll num = (a[1] > a[2] ? -1 : 1);
for(i = 2 ; i < n ; i++){
if((num == 1 && a[i + 1] >= a[i]) || (num == -1 && a[i + 1] <= a[i])){
ok = false;
break;
}
num *= -1;
}
if(ok) ans++;
}
}while(next_permutation(a + 1 , a + n + 1));
cout << ans << endl;
}
signed main(){
speedyboy;
open;
ll t = 1;
//cin >> t;
while(t--){
solve();
}
}
Compilation message (stderr)
# | 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... |