# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
838954 | rahidilbayramli | Kangaroo (CEOI16_kangaroo) | C++17 | 2066 ms | 300 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>
#define ll long long
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(), v.end()
#define pb push_back
#define f first
#define s second
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
int main()
{
ll n, cs, cf, i, j, ans = 0, k = 0;
cin >> n >> cs >> cf;
int v[n+1];
for(i = 1; i <= n; i++)
v[i] = i;
while(next_permutation(v+1, v+n+1))
{
k = 0;
if(v[1] == cs && v[n] == cf)
{
k = 2;
for(i = 2; i <= n - 1; i++)
{
if((v[i] > v[i-1] && v[i] > v[i+1]) || (v[i] < v[i-1] && v[i] < v[i+1]))
k++;
}
if(k == n)
ans++;
ans %= 1000000007;
}
}
cout << ans << "\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... |