This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
using namespace std;
const int mod = 1e9 + 7;
int mult(int x, int y) {
return x * 1ll * y % mod;
}
void add(int &x, int y) {
x += y;
if (x >= mod) x -= mod;
}
int ad(int x, int y) {
add(x, y);
return x;
}
int dp[22][22][22][2];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int N, cs, cf;
cin >> N >> cs >> cf;
dp[1][1][1][0] = dp[1][1][1][1] = 1;
for (int n = 1 ; n < N ; ++ n) {
for (int x = 1 ; x <= n ; ++ x) {
for (int y = 1 ; y <= n ; ++ y) {
for (int z = 1 ; z <= y ; ++ z) {
add(dp[n+1][x+1][z][0], dp[n][x][y][1]);
}
for (int z = y + 1 ; z <= n + 1 ; ++ z) {
add(dp[n+1][x][z][1], dp[n][x][y][0]);
}
}
}
}
cout << ad(dp[N][cs][cf][0], dp[N][cs][cf][1]);
}
# | 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... |