# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
307369 | jungsnow | Kangaroo (CEOI16_kangaroo) | C++14 | 2 ms | 384 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;
int main() {
freopen("kangaroo.in", "r", stdin);
freopen("kangaroo.out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, st, en;
cin >> n >> st >> en;
int cn = 0;
vector<int> v;
int a[2001];
for (int i = 1; i <= n; ++i) if (i != st && i != en) {
v.push_back(i);
}
a[1] = st; a[n] = en;
do {
for (int i = 0; i < (int)v.size(); ++i)
a[i + 2] = v[i];
bool ok = 1;
for (int i = 2; i < n; ++i) {
if (a[i] > a[i - 1]) {
if (a[i] < a[i + 1]) {
ok = 0;
break;
}
} else if (a[i] > a[i + 1]) {
ok = 0;
break;
}
}
// if (ok) {
// for (int i = 1; i <= n; ++i)
// cout << a[i] << ' ';
// cout << '\n';
// }
cn += ok;
} while (next_permutation(v.begin(), v.end()));
cout << cn << '\n';
}
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... |