結果

問題 No.2867 NOT FOUND 404 Again
コンテスト
ユーザー vjudge1
提出日時 2024-09-12 22:17:10
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 937 ms / 3,000 ms
コード長 1,141 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,764 ms
コンパイル使用メモリ 334,040 KB
実行使用メモリ 262,432 KB
最終ジャッジ日時 2026-04-04 01:58:18
合計ジャッジ時間 21,871 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge5_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
#define int long long
using namespace std;
#define fi first
#define sc second
#define pii pair<int,int>
#define pb push_back
#define umap unordered_map
#define mset multiset
#define pq priority_queue
#define ull unsigned long long
#define i128 __int128
const int maxn=1e6+10;
const int mod=998244353;
string s;
int n,a[maxn],f[maxn][3][3][2];
/*
0 -> None
1 -> 0
2 -> 4
*/
int dfs(int x,int lst,int llst,bool flg){
    if(!x) return 1;
    if(~f[x][lst][llst][flg]) return f[x][lst][llst][flg];
    int up=(flg?a[x]:9),res=0;
    for(int i=0;i<=up;i++){
        if(lst==1&&llst==2&&i==4) continue;
        int num=((i==4)?2:(i==0?1:0));
        res=(res+dfs(x-1,num,lst,flg&(i==a[x])))%mod; 
    }
    return f[x][lst][llst][flg]=res;
}
void solve(){
    cin>>s,n=s.size(),s=" "+s,memset(f,-1,sizeof f);
    for(int i=1;i<=n;i++) a[i]=(s[n-i+1]-'0');
    cout<<(dfs(n,0,0,1)-1+mod)%mod<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}
/*
Samples
input:

output:

THINGS TODO:
??freopen???????
????
????????????
*/
0