# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
48121 | 2018-05-10T06:03:06 Z | Extazy | 캥거루 (CEOI16_kangaroo) | C++17 | 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 484 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | - |
# | 결과 | 실행 시간 | 메모리 | 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 | - |
# | 결과 | 실행 시간 | 메모리 | 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 | - |