이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
using namespace std;
int dp[200][200][200][2][2], seen[200][200][200][2][2], mod = 1e9 + 7;
void Add(int &a, int b){
a += b;
if (a >= mod)
a -= mod;
}
int calc(int a, int b, int c, bool pos, bool rgt){
if (seen[a][b][c][pos][rgt])
return dp[a][b][c][pos][rgt];
seen[a][b][c][pos][rgt] = 1;
if (pos){
for (int i=1;i<=b;i++)
Add(dp[a][b][c][pos][rgt], calc(a, b - i, c + i - 1, 1, !rgt) * (rgt == 1));
for (int i=1;i<=a;i++)
Add(dp[a][b][c][pos][rgt], calc(a - i, i - 1, b + c, 0, !rgt) * (rgt == 1));
for (int i=1;i<=c;i++)
Add(dp[a][b][c][pos][rgt], calc(a, b + i - 1, c - i, 1, !rgt) * (rgt == 0));
return dp[a][b][c][pos][rgt];
}
for (int i=1;i<=a;i++)
Add(dp[a][b][c][pos][rgt], calc(a - i, b + i - 1, c, 0, !rgt) * (rgt == 1));
for (int i=1;i<=b;i++)
Add(dp[a][b][c][pos][rgt], calc(a + i - 1, b - i, c, 0, !rgt) * (rgt == 0));
for (int i=1;i<=c;i++)
Add(dp[a][b][c][pos][rgt], calc(a + b, i - 1, c - i, 1, !rgt) * (rgt == 0));
return dp[a][b][c][pos][rgt];
}
int main(){
int n, st, en, Ans = 0;
cin>>n>>st>>en;
if (st > en)
swap(st, en);
seen[0][0][0][0][0] = seen[0][0][0][1][1] = 1;
dp[0][0][0][0][0] = dp[0][0][0][1][1] = 1;
for (bool b : {0, 1})
Add(Ans, calc(st - 1, en - st - 1, n - en, 0, b));
cout<<Ans<<'\n';
}
# | 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... |