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>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set ;
#define int long long
#define F first
#define S second
#define rep(i , j , n ) for(int i = j ;i < n; i++ )
#define FOR(i , n ) rep(i ,0 , n )
#define sz size()
#define pb push_back
#define all(x) x.begin() , x.end()
#define vi vector<int>
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define cans cout<<ans<<endl;
#define forx(i, x) for(auto &i : x)
#define fast
#define pii pair<int ,int >
#define endl "\n"
#define sp ' '
#define test int t ; cin >> t ; while(t--)
const int N = 300 ;
const int inf = 1e15 ;
int n , s ,e;
int rec(int i , bool prev , int jumps ) {
if(jumps==n-1)if(i==e)return 1 ;else return 0 ;
if(i==0)return 0 ;
int ans = 0 ;
if(prev == 0 ){
rep(j , i+1 , n+1 ){
ans += rec(j, prev^1, jumps+1);
}
}else {
rep(j , 0 , i ) {ans += rec(j , prev^1 , jumps+1 ) ; }
}
return ans ;
}
main()
{
cin >> n >> s >> e ;
cout<<rec(s , 0 , 0 )/2;
}
Compilation message (stderr)
kangaroo.cpp: In function 'long long int rec(long long int, bool, long long int)':
kangaroo.cpp:27:7: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
27 | if(jumps==n-1)if(i==e)return 1 ;else return 0 ;
| ^
kangaroo.cpp: At global scope:
kangaroo.cpp:41:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
41 | main()
| ^~~~
# | 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... |