# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
30665 | jenkhai | Kangaroo (CEOI16_kangaroo) | C++14 | 2000 ms | 2020 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;
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 (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... |