結果

問題 No.430 文字列検索
コンテスト
ユーザー GrayCoder
提出日時 2018-09-22 06:35:20
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 439 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 56 ms
コンパイル使用メモリ 14,976 KB
実行使用メモリ 13,432 KB
最終ジャッジ日時 2026-09-21 16:42:00
合計ジャッジ時間 7,325 ms
ジャッジサーバーID
(参考情報)
judge5_1 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other AC * 2 TLE * 1 -- * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import defaultdict
from sys import stdin

input = lambda: stdin.readline().rstrip()

def main():
    S = input()
    M = int(input())
    C = stdin.read().splitlines()

    strings = defaultdict(list)
    for i, s in enumerate(S):
        strings[s].append(i)

    ans = 0
    for ci in C:
        l = len(ci)
        for i in strings[ci[0]]:
            if S[i:i+l] == ci:
                ans += 1
    print(ans)

main()
0