이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define pb push_back
#define maxn 1000005
#define mod 1000000007
#define val first
#define poj second
using namespace std;
int n;
int poc,kraj;
ll dp[205][205][205][2];
void calc()
{
for(int duz=2;duz<=n;duz++)
{
//cout<<endl<<endl;
//cout<<duz<<endl;
for(int i=1;i<=duz;i++)
{
for(int j=i+1;j<=duz;j++)
{
if(i==1)
{
dp[duz][i][j][0] = 0;
if(duz==2)
{
dp[duz][i][j][1] = 1;
}
}
else
{
dp[duz][i][j][0] = dp[duz][i-1][j][0] + dp[duz - 1][i-1][j-1][1];
dp[duz][i][j][0] %= mod;
}
}
}
for(int i=duz;i>0;i--)
{
for(int j=i+1;j<=duz;j++)
{
if(i + 1 == j)
{
for(int k=j;k<=duz-1;k++)
{
dp[duz][i][j][1] += dp[duz-1][j-1][k][duz%2];
dp[duz][i][j][1] %= mod;
}
}
else
{
dp[duz][i][j][1] = dp[duz][i+1][j][1] + dp[duz - 1][i][j-1][0];
dp[duz][i][j][1] %= mod;
}
}
}
/*for(int i=1;i<=duz;i++)
{
cout<<i<<": ";
for(int j=i+1;j<=duz;j++)
{
cout<<j<<","<<dp[duz][i][j][0]<<","<<dp[duz][i][j][1]<<" ";
}
cout<<endl;
}*/
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin>>n>>poc>>kraj;
if(poc > kraj)swap(poc,kraj);
calc();
cout<<(dp[n][poc][kraj][0] + dp[n][poc][kraj][1])%mod<<endl;
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... |