Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Problem: E - Distance Sequence
- // Contest: AtCoder - NOMURA Programming Contest 2022(AtCoder Beginner Contest 253)
- // URL: https://atcoder.jp/contests/abc253/tasks/abc253_e
- // Memory Limit: 1024 MB
- // Time Limit: 2000 ms
- //
- // Powered by CP Editor (https://cpeditor.org)
- #include <assert.h>
- #include <bits/stdc++.h>
- #include <atcoder/modint>
- using namespace std;
- #ifndef __DEBUG__
- #define dbg(...) 42
- #endif
- template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
- using ll = long long;
- using pii = pair<int, int>;
- using pll = pair<ll, ll>;
- using vl = vector<ll>;
- using vi = vector<int>;
- using mint = atcoder::modint998244353;
- int main(int argc, char **argv)
- {
- int n, m, k;
- cin >> n >> m >> k;
- vector<mint> dp(m, 1);
- for (int i = 2; i <= n; ++i) {
- vector<mint> ndp(m);
- vector<mint> acc(m + 1);
- for (int j = 0; j < m; ++j)
- acc[j + 1] = acc[j] + dp[j];
- for (int j = 0; j < m; ++j) {
- if (j >= k)
- ndp[j] += acc[j - k + 1];
- if (j + k <= m)
- ndp[j] += acc[m] - acc[j + k];
- }
- dp.swap(ndp);
- }
- mint ans = 0;
- for (auto x : dp)
- ans += x;
- cout << ans.val() << endl;
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement