Submission #797816

#TimeUsernameProblemLanguageResultExecution timeMemory
797816amirhoseinfar1385Kangaroo (CEOI16_kangaroo)C++17
0 / 100
1 ms340 KiB
#include<bits/stdc++.h> using namespace std; const int maxn=200+10; int mod=1e9+7; long long dp[maxn][maxn][maxn][2],pd[maxn][maxn]; int n,s,e; int ww(long long a){ a%=mod; return a; } void calpd(){ pd[1][1]=1; for(int i=2;i<=n;i++){ if((i&1)==0){ for(int j=1;j<=i;j++){ pd[i][j]=pd[i][j-1]+pd[i-1][i-j+1]; pd[i][j]=ww(pd[i][j]); } } else{ for(int j=2;j<=i;j++){ pd[i][j]=pd[i][j-1]+mod-pd[i-1][j-1]+pd[i-1][i-j+1]; pd[i][j]=ww(pd[i][j]); } } } } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>s>>e; if(s>e){ swap(s,e); } calpd(); dp[0][0][0][0]=1; for(int sum=1;sum<=n;sum++){ for(int fn=1;fn<=sum;fn++){ for(int i=sum-fn;i>=0;i--){ int j=sum-fn-i; for(int k=0;k<2;k++){ dp[fn][i][j][k]=dp[fn-1][i+1][j][k]; if(k==0){ dp[fn][i][j][k]+=pd[j+i+fn][j+1]; dp[fn][i][j][k]+=dp[fn-1][i][j][k^1]; } else{ dp[fn][i][j][k]+=pd[fn+i+j][fn+i]; dp[fn][i][j][k]+=mod-dp[fn-1][i][j][k^1]; } dp[fn][i][j][k]=ww(ww(dp[fn][i][j][k])); } } } } int res=ww(dp[e-s][s-1][n-e][0]+dp[e-s][s-1][n-e][1]); s++; res+=mod-ww(dp[e-s][s-1][n-e][0]+dp[e-s][s-1][n-e][1]); res=ww(res); cout<<res<<"\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...