結果
問題 |
No.430 文字列検索
|
ユーザー |
![]() |
提出日時 | 2023-04-11 14:13:03 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 456 ms / 2,000 ms |
コード長 | 441 bytes |
コンパイル時間 | 402 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 137,256 KB |
最終ジャッジ日時 | 2024-11-10 01:06:07 |
合計ジャッジ時間 | 4,822 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 14 |
ソースコード
from collections import defaultdict b=30 def str_to_num(s): res=[] for ss in s: res.append(ord(ss)-ord("A")+1) return res def calc_h(s): L=str_to_num(s) h=0 for i in range(len(L)): h+=L[i]*b**i return h S=input() d=defaultdict(int) for i in range(1,11): for j in range(len(S)-i+1): d[calc_h(S[j:j+i])]+=1 ans=0 M=int(input()) for _ in range(M): ans+=d[calc_h(input())] print(ans)