| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 48121 | Extazy | Kangaroo (CEOI16_kangaroo) | C++17 | 2 ms | 568 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>
#define endl '\n'
using namespace std;
const int N = 20;
int n,cs,cf,fact[N],a[N],ans;
bool check() {
  for(int i=2;i<n;i++) {
    if(!((a[i-1]<a[i] && a[i+1]<a[i]) || (a[i-1]>a[i] && a[i+1]>a[i]))) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i,j;
  scanf("%d %d %d", &n, &cs, &cf);
  fact[0]=1;
  for(i=1;i<=n-2;i++) {
    fact[i]=fact[i-1]*i;
  }
  for(i=1;i<=n;i++) {
    a[i]=i;
  }
  swap(a[1],a[cs]);
  swap(a[n],a[cf]);
  for(j=1;j<=fact[n-2];j++) {
    next_permutation(a+2,a+n);
    if(check()) ++ans;
  }
  printf("%d\n", ans);
  return 0;
}
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... | ||||
