結果
問題 |
No.3213 depth max K
|
ユーザー |
![]() |
提出日時 | 2025-07-28 18:14:06 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,353 bytes |
コンパイル時間 | 3,025 ms |
コンパイル使用メモリ | 281,636 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-07-28 18:14:33 |
合計ジャッジ時間 | 26,149 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 TLE * 2 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/modint> using namespace std; using namespace atcoder; using ll = long long; using mint = modint998244353; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); /* dp(i, j, k) = i文字目までで深さがjであり、Kに到達したか(k)? */ int N, K; const int c = 998244353; cin >> N >> K; vector dp(K+1, vector<int>(2)); dp[0][0] = 1; for (int i=1; i<=N*2; i++){ vector pd(K+1, vector<int>(2)); for (int j=0; j<=K; j++){ // (にする。 if (j == K){ pd[j][1] += dp[j-1][0]; if (pd[j][1] >= c) pd[j][1] -= c; pd[j][1] += dp[j-1][1]; if (pd[j][1] >= c) pd[j][1] -= c; } else if (j > 0){ pd[j][0] += dp[j-1][0]; if (pd[j][0] >= c) pd[j][0] -= c; pd[j][1] += dp[j-1][1]; if (pd[j][1] >= c) pd[j][1] -= c; } // )にする。 if (j+1 <= K){ pd[j][0] += dp[j+1][0]; if (pd[j][0] >= c) pd[j][0] -= c; pd[j][1] += dp[j+1][1]; if (pd[j][1] >= c) pd[j][1] -= c; } } swap(dp, pd); } cout << dp[0][1] << endl; return 0; }