# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
966789 | berr | Kangaroo (CEOI16_kangaroo) | C++17 | 3 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;
const int N = 2005;
int dp[N][N][2];
int calc(int n, int cs, int cf, int dir){
if(n==2 && (cs<cf)==dir) return 1;
else if(n==2) return 0;
if(dir==0&&cs==0||dir==1&&cs==n-1) return 0;
int v=0, check=0, ans=0;
if(dir==0){
for(int i=0; i<cs; i++, v++){
if(i==cs||i==cf){
if(i==cs) cs--;
continue;
}
else{
ans+=calc(n-1, v, cf-(cs<cf), 1);
}
}
}
else{
int v=cs;
for(int i=cs+1; i<n; i++, v++){
if(i==cs||i==cf){
if(i==cs)v--;
continue;
}
else{
ans+=calc(n-1, v, cf-(cs<cf), 0);
}
}
}
//cout<<n<<" "<<cs<<" "<<cf<<" "<<dir<<" "<<ans<<"\n";
return ans;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
freopen("kangaroo.in", "r", stdin);
freopen("kangaroo.out", "w", stdout);
int n, cs, cf; cin >> n >> cs >> cf;
cs--; cf--;
cout<<calc(n, cs, cf, 0)+calc(n, cs, cf, 1);
}
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... |