結果
問題 |
No.3213 depth max K
|
ユーザー |
|
提出日時 | 2025-07-25 22:08:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 165 ms / 2,000 ms |
コード長 | 802 bytes |
コンパイル時間 | 1,736 ms |
コンパイル使用メモリ | 195,500 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-07-25 22:08:10 |
合計ジャッジ時間 | 4,417 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 998244353; const int N = 200005; const int INF = 0x3f3f3f3f; int solve(int n, int k) { vector<int> f(k + 1, 0), g(k + 1, 0); f[0] = 1; int tot = 2 * n; for (int s = 0; s < tot; s++) { fill(g.begin(), g.end(), 0); for (int h = 0; h <= k; h++) { int v = f[h]; if (!v) continue; if (h + 1 <= k) g[h + 1] = (g[h + 1] + v) % mod; if (h > 0) g[h - 1] = (g[h - 1] + v) % mod; } f.swap(g); } return f[0]; } int main() { int n, k; cin >> n >> k; int tot = solve(n, k); int tot2 = (k >= 1 ? solve(n, k - 1) : 0); int ans = tot - tot2; if (ans < 0) ans += mod; cout << ans << "\n"; return 0; }