Submission #48121

# Submission time Handle Problem Language Result Execution time Memory
48121 2018-05-10T06:03:06 Z Extazy Kangaroo (CEOI16_kangaroo) C++17
6 / 100
2 ms 568 KB
#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

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &n, &cs, &cf);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Runtime error 2 ms 568 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Runtime error 2 ms 568 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Runtime error 2 ms 568 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -