# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
607347 | A_D | Kangaroo (CEOI16_kangaroo) | C++14 | 0 ms | 340 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 int long long
#define ii pair<int,int>
#define F first
#define S second
using namespace std;
const int MOD=1e9+7;
int dp[2123][2123];
void solve()
{
int n,s,e;
cin>>n>>s>>e;
if(s!=1&&e!=1)dp[1][2]=1;
else dp[1][1]=1;
for(int i=2;i<=n;i++){
for(int j=0;j<=n;j++){
if(i==s||i==e){
if(j>1){
dp[i][j]+=dp[i-1][j-1];
dp[i][j]%=MOD;
}
dp[i][j]+=dp[i-1][j+1];
dp[i][j]%=MOD;
}
else{
if(j>2){
dp[i][j]+=dp[i-1][j-2];
dp[i][j]%=MOD;
}
dp[i][j]+=dp[i-1][j+2];
dp[i][j]%=MOD;
}
// cout<<dp[i][j]<<" ";
}
// cout<<"\n";
}
cout<<dp[n][0]<<"\n";
}
main()
{
/*
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// */
int t=1;
// cin>>t;
while(t--){
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... |