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 <bits/stdc++.h>
using namespace std;
constexpr int NMAX = 2005;
constexpr int MOD = 1e9 + 7;
int N, cs, cf;
int dp[NMAX][2][NMAX];
void Add (int &x, int y) {
x = x + y;
if (x >= MOD) x -= MOD;
}
int main () {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N >> cs >> cf;
dp[0][0][cs-1] = 1;
dp[0][1][cs-1] = 1;
for (int i = 0; i < N-2; ++ i ) {
for (int cnt_st = 0; cnt_st <= (N-2) - i; ++ cnt_st ) {
int cnt_dr = (N-2) - i - cnt_st;
assert(cnt_dr >= 0);
for (int j = 1; j <= cnt_dr; ++ j )
Add(dp[i+1][1][cnt_st + (j-1)], dp[i][0][cnt_st]);
for (int j = 1; j <= cnt_st; ++ j )
Add(dp[i+1][0][cnt_st-j], dp[i][1][cnt_st]);
}
}
int sol = 0;
Add(sol, dp[N-2][0][0]);
Add(sol, dp[N-2][1][0]);
cout << sol << '\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... |