結果
| 問題 | No.430 文字列検索 | 
| コンテスト | |
| ユーザー |  takakin | 
| 提出日時 | 2020-04-24 00:41:36 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                RE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 526 bytes | 
| コンパイル時間 | 82 ms | 
| コンパイル使用メモリ | 12,928 KB | 
| 実行使用メモリ | 52,616 KB | 
| 最終ジャッジ日時 | 2024-11-10 00:43:40 | 
| 合計ジャッジ時間 | 8,391 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 RE * 3 | 
| other | AC * 13 RE * 1 | 
ソースコード
import sys
input=lambda: sys.stdin.readline().rstrip()
S=input()
n=len(S)
m=int(input())
import collections
RH=collections.defaultdict(int)
base=37;mod=10**9+7
for l in range(10):
  v=0
  for i in range(l+1):
    v=((v+ord(S[i]))*base)%mod
  RH[v]+=1
  for i in range(l+1,n):
    v=(((v-ord(S[i-l-1])*pow(base,l+1,mod))+ord(S[i]))*base)%mod
    RH[v]+=1
ans=0
for _ in range(m):
  C=input()
  lc=len(C)
  if lc>n:
    continue
  else:
    v=0
    for i in range(lc):
      v=((v+ord(C[i]))*base)%mod
    ans+=RH[v]
print(ans)
            
            
            
        