이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 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... |