結果
問題 |
No.2867 NOT FOUND 404 Again
|
ユーザー |
|
提出日時 | 2024-09-01 08:28:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 113 ms / 3,000 ms |
コード長 | 880 bytes |
コンパイル時間 | 4,024 ms |
コンパイル使用メモリ | 251,424 KB |
最終ジャッジ日時 | 2025-02-24 03:39:42 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using ll = long long; using mint = atcoder::modint998244353; int main(){ ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; const int n = s.size(); array<int, 3> tmp = {4, 0, 4}; array<mint, 8> dp{}; dp[1] = 1; for(int i = 0; i < n; i++){ array<mint, 8> ndp{}; for(int S = 0; S < 8; S++){ if(dp[S] == 0) continue; const int r = S & 1 ? s[i] - '0' : 9; if((S & 6) == 6){ if(S & 1){ ndp[7] += dp[S]; if(r >= 1) ndp[6] += r * dp[S]; }else{ ndp[6] += 10 * dp[S]; } }else{ const int fl = S & 1, st = S >> 1; for(int nv = 0; nv <= r; nv++){ int ns = tmp[st] == nv ? st + 1 : (nv == 4); ndp[ns * 2 + ((nv == r) & fl)] += dp[S]; } } } swap(dp, ndp); } cout << accumulate(dp.begin(), dp.begin() + 6, mint(-1)).val() << '\n'; }