# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
30665 | 2017-07-26T04:14:39 Z | jenkhai | 캥거루 (CEOI16_kangaroo) | C++14 | 2000 ms | 2020 KB |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9+7; const int MAXN = 2010; int N, src, dst; vector<int> v; bool ok() { if(v[0] != src) return false; if(v[N-1] != dst) return false; bool ret = true; for(int i=0;i<N-1;i++) { if(i%2 == 0) { if(v[i+1] > v[i]) ret = false; } else { if(v[i+1] < v[i]) ret = false; } } if(ret == true) return ret; ret = true; for(int i=0;i<N-1;i++) { if(i%2 == 1) { if(v[i+1] > v[i]) ret = false; } else { if(v[i+1] < v[i]) ret = false; } } return ret; } void print() { for(int i=0;i<N;i++) printf("%d ", v[i]); printf("ok:%d\n", ok()); } int main() { scanf("%d %d %d", &N, &src, &dst); long long ans = 0; for(int i=1;i<=N;i++) v.push_back(i); do { //print(); if(ok()) ans++; } while(next_permutation(v.begin(), v.end())); printf("%lld\n", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2020 KB | Output is correct |
2 | Correct | 0 ms | 2020 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2020 KB | Output is correct |
2 | Correct | 0 ms | 2020 KB | Output is correct |
3 | Execution timed out | 2000 ms | 2020 KB | Execution timed out |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2020 KB | Output is correct |
2 | Correct | 0 ms | 2020 KB | Output is correct |
3 | Execution timed out | 2000 ms | 2020 KB | Execution timed out |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2020 KB | Output is correct |
2 | Correct | 0 ms | 2020 KB | Output is correct |
3 | Execution timed out | 2000 ms | 2020 KB | Execution timed out |
4 | Halted | 0 ms | 0 KB | - |