結果

問題 No.2867 NOT FOUND 404 Again
ユーザー Yotugi
提出日時 2025-06-02 11:16:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 232 ms / 3,000 ms
コード長 1,832 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 86,644 KB
最終ジャッジ日時 2025-06-02 11:16:44
合計ジャッジ時間 5,798 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin,setrecursionlimit#,set_int_max_str_digits
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')
setrecursionlimit(20000000) # これこどふぉだと無理
#set_int_max_str_digits(200010)
mod = 998244353 
ii = lambda :int(stdin.readline())
mi = lambda :map(int,stdin.readline().split())
li = lambda :list(mi())
gmi = lambda :map(lambda x: int(x) - 1, stdin.readline().split())
gi = lambda :list(map(lambda x: 0 if x == "." else 1,input())) # グリッド入力受け取り
py = lambda :print("Yes")
pn = lambda :print("No")
pf = lambda :print("First") 
ps = lambda :print("Second")
vec = [(1,0),(-1,0),(0,-1),(0,1)]
vec1 = [(1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1)] #8方向
inf = 2*10**18
from collections import defaultdict,deque 
from heapq import heappop,heappush


a = [int(i) for i in input()]

tie = 1 
dp = 0 
dp1 = 0 
dp2 = 0 

for i,x in enumerate(a):
    ndp = 0 
    ndp1 = 0 
    ndp2 = 0
    for j in range(10):
        if j == 4:
            ndp1 += dp
        else:
            ndp += dp + dp2

        if j == 0:
            ndp2 += dp1 
        elif j == 4:
            ndp1 += dp1
        else:
            ndp += dp1 
        
        if tie == 0:
            continue 

        if j < x:
            if j == 4:
                if i and a[i-2:i] == [4,0]:
                    continue 
                ndp1 += 1 
            elif j == 0:
                if i and a[i-1] == 4:
                    ndp2 += 1 
                else:
                    ndp += 1 
            else:
                ndp += 1 
        
        if j == x:
            if a[i-2:i+1] == [4,0,4]:
                tie = 0 

    dp = ndp % mod 
    dp1 = ndp1 % mod
    dp2 = ndp2 % mod 

    # print(dp)
    # print(dp1)
    # print(dp2)
    # print()


print((dp+dp1+dp2-1+tie)%mod) 


        

0