Submission #797821

#TimeUsernameProblemLanguageResultExecution timeMemory
797821amirhoseinfar1385Kangaroo (CEOI16_kangaroo)C++17
6 / 100
2084 ms388 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; pd[2][1]=0; pd[2][2]=1; for(int i=3;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-1][j-1]; pd[i][j]=ww(pd[i][j]); // cout<<i<<" "<<j<<" "<<pd[i][j]<<"\n"; } } 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]); // cout<<i<<" "<<j<<" "<<pd[i][j]<<"\n"; } } } } long long caldp(int fn,int i,int j,int k){ long long res=0; if(fn==0){ if(i==0&&j==0&&k==0){ return 1; } return 0; } res+=caldp(fn-1,i+1,j,k); if(k==0){ res+=pd[j+i+fn][j+1]; res+=caldp(fn-1,i,j,k^1); } else{ res+=pd[fn+i+j][fn+i]; res+=mod-caldp(fn-1,i,j,k^1); } res=ww(ww(res)); return res; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>s>>e; if(s>e){ swap(s,e); } calpd(); int res=ww(caldp(e-s,s-1,n-e,0)+caldp(e-s,s-1,n-e,1)); s++; res+=mod-ww(caldp(e-s,s-1,n-e,0)+caldp(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...