# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1117633 | vjudge1 | Kangaroo (CEOI16_kangaroo) | C++17 | 2049 ms | 336 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 int long long
void solve()
{
int n, cs, cf, ans = 0;
cin >> n >> cs >> cf;
vector < int > per;
for(int i = 1; i <= n; i++)
per.push_back(i);
while(next_permutation(per.begin(), per.end()))
{
if(per[0] != cs || per[per.size() - 1] != cf) continue;
int cnt = 2;
for(int i = 1; i < per.size() - 1; i++)
{
if(per[i] > per[i - 1] && per[i] > per[i + 1] || per[i] < per[i - 1] && per[i] < per[i + 1])
cnt++;
}
if(cnt == n)
ans++;
}
cout << ans << endl;
}
signed main()
{
int tt = 1;
// cin >> tt;
while(tt--)
solve();
}
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... |