# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
893609 | vjudge1 | Kangaroo (CEOI16_kangaroo) | C++17 | 2057 ms | 504 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;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
const int N = (int)2e5 + 5;
const int MAX = (int)1e9 + 5;
const ll mod = (int)1e9 + 7;
const ll inf = (int)(1e9) + 100;
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
void solve() {
int n;
cin >> n;
int cs, cf;
cin >> cs >> cf;
vector<int> p;
for (int i = 1; i <= n; i++) {
p.pb(i);
}
int ans = 0;
do {
if (p[0] != cs) continue;
if (p.back() != cf) continue;
bool bad = 0;
for (int i = 1; i < sz(p) - 1; i++) {
if (!((p[i] > p[i - 1] && p[i] > p[i + 1]) || (p[i] < p[i - 1] && p[i] < p[i + 1]))) {
bad = 1;
break;
}
}
ans += !bad;
ans %= mod;
} while (next_permutation(all(p)));
cout << ans;
}
signed main() {
//setIO("kangaroo");
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int T = 1;
//cin >> T;
while (T--) solve();
return 0;
}
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... |