結果

問題 No.430 文字列検索
コンテスト
ユーザー masatosis
提出日時 2022-05-12 15:14:33
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 417 ms / 2,000 ms
+ 36µs
コード長 510 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 52 ms
コンパイル使用メモリ 14,464 KB
実行使用メモリ 53,220 KB
最終ジャッジ日時 2026-10-15 20:34:10
合計ジャッジ時間 6,247 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import Counter, defaultdict
from random import randint


S = input()
# hash_dict = defaultdict(lambda: randint(1, (1 << 64) - 1))
d = Counter()
for i in range(len(S)):
    for j in range(1, 11):
        if i + j > len(S):
            continue
        # print(i, j, S[i : i + j + 1])
        # d[hash_dict[S[i : i + j]]] += 1
        d[S[i : i + j]] += 1

# print(d, hash_dict)
M = int(input())
ans = 0
for _ in range(M):
    C = input()
    # ans += d[hash_dict[C]]
    ans += d[C]
print(ans)
0