結果

問題 No.430 文字列検索
ユーザー mitsuomitsuo
提出日時 2018-08-24 10:06:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 438 ms / 2,000 ms
コード長 430 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 10,620 KB
実行使用メモリ 52,944 KB
最終ジャッジ日時 2023-09-02 08:35:53
合計ジャッジ時間 4,960 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,836 KB
testcase_01 AC 438 ms
52,944 KB
testcase_02 AC 313 ms
8,580 KB
testcase_03 AC 318 ms
8,500 KB
testcase_04 AC 16 ms
7,832 KB
testcase_05 AC 16 ms
7,836 KB
testcase_06 AC 16 ms
7,760 KB
testcase_07 AC 16 ms
7,924 KB
testcase_08 AC 420 ms
52,508 KB
testcase_09 AC 17 ms
7,856 KB
testcase_10 AC 49 ms
11,376 KB
testcase_11 AC 333 ms
14,476 KB
testcase_12 AC 339 ms
14,300 KB
testcase_13 AC 337 ms
14,388 KB
testcase_14 AC 326 ms
11,744 KB
testcase_15 AC 321 ms
10,316 KB
testcase_16 AC 315 ms
8,536 KB
testcase_17 AC 313 ms
8,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(S, Cs):
    counts = {}
    for i in range(1, 11):
        for k in range(0, len(S)):
            if k + i > len(S): continue

            counts.setdefault(S[k:k+i], 0)
            counts[S[k:k+i]] += 1

    sum = 0
    for C in Cs:
        if C in counts:
            sum += counts[C]
    return sum

if __name__ == "__main__":
    S = input()
    M = int(input())
    print(solve(S, [input() for _ in range(0, M)]))
0