結果

問題 No.430 文字列検索
コンテスト
ユーザー ああ
提出日時 2025-10-14 00:35:26
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 509 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 39,988 KB
最終ジャッジ日時 2025-10-14 00:35:38
合計ジャッジ時間 11,019 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

mod=10**9+7
s=list(map(lambda x:ord(x),list(input())))
x=[{} for i in range(11)]
for i in range(1,11):
	f=deque();c=0;d=10**i%mod
	for j in range(len(s)):
		c*=10;c%=mod
		if len(f)>=i:
			c+=mod-f.popleft()*d%mod
			c%=mod
		c+=s[j];c%=mod
		f.append(s[j])
		if c not in x[i]:
			x[i][c]=0
		x[i][c]+=1
m=int(input());ans=0
for i in range(m):
	s=list(input())
	c=0
	for j in s:
		c*=10;c+=ord(j)
		c%=mod
	if c not in x[len(s)]:
		continue
	else:
		ans+=x[len(s)][c]
print(ans)
0