# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1005053 | erering | Kangaroo (CEOI16_kangaroo) | C++17 | 2086 ms | 348 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 endl '\n'
#define pb push_back
#define ll long long
#define int long long
const long long inf=1e18;
const int MOD=1e9+7;
const int N=41;
int n,cs,cf,ans=0;
void func(int i,set<int> s,bool flag){
if(s.size()==n && i==cf){
ans++;
return;
}
if(flag){
for(int j=i+1;j<=n;j++){
if(!s.count(j)){
s.insert(j);
func(j,s,0);
s.erase(j);
}
}
}
else{
for(int j=i-1;j>0;j--){
if(!s.count(j)){
s.insert(j);
func(j,s,1);
s.erase(j);
}
}
}
}
signed main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>cs>>cf;
set<int> s;
s.insert(cs);
func(cs,s,0);
func(cs,s,1);
cout<<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... |