結果
問題 |
No.2867 NOT FOUND 404 Again
|
ユーザー |
|
提出日時 | 2024-08-30 22:47:33 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,304 bytes |
コンパイル時間 | 1,107 ms |
コンパイル使用メモリ | 102,332 KB |
実行使用メモリ | 207,740 KB |
最終ジャッジ日時 | 2024-08-30 22:47:42 |
合計ジャッジ時間 | 5,744 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 1 TLE * 1 -- * 16 |
ソースコード
#include <iostream> #include <map> #include <vector> #include <string> #include <tuple> using namespace std; using ll = long long; int main () { string n; cin >> n; vector<int> N(n.size()); for (int i = 0; i < n.size(); i++) N[i] = n[i] - '0'; const int len = static_cast<int>(n.size()); const ll MOD = 998244353; const auto ban = vector<int>({4, 0, 4}); map<tuple<int, bool, int>, ll> mp; auto dp = [&] (auto dp, int pos, bool less, int cur) { auto key = make_tuple(pos, less, cur); if (mp.find(key) != mp.end()) return mp[key]; if (pos == len) { if (cur == 3) return 0LL; return 1LL; } ll res = 0; for (int nex = 0; nex < 10; nex++) { if (!less && N[pos] < nex) continue; bool nl = less || nex < N[pos]; int nc = cur; if (nc < 3) { if (ban[nc] == nex) { nc++; } else if (nex == 4) { nc = 1; } else { nc = 0; } } res += dp(dp, pos + 1, nl, nc); res %= MOD; } return mp[key] = res; }; cout << dp(dp, 0, false, 0) - 1 << "\n"; }