結果

問題 No.430 文字列検索
ユーザー masatosismasatosis
提出日時 2022-05-12 15:14:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 525 ms / 2,000 ms
コード長 510 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 10,724 KB
実行使用メモリ 53,576 KB
最終ジャッジ日時 2023-09-27 14:44:14
合計ジャッジ時間 5,859 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
9,144 KB
testcase_01 AC 507 ms
53,576 KB
testcase_02 AC 389 ms
9,068 KB
testcase_03 AC 377 ms
9,224 KB
testcase_04 AC 20 ms
9,004 KB
testcase_05 AC 20 ms
9,040 KB
testcase_06 AC 18 ms
9,104 KB
testcase_07 AC 19 ms
9,052 KB
testcase_08 AC 525 ms
53,488 KB
testcase_09 AC 19 ms
8,940 KB
testcase_10 AC 56 ms
12,228 KB
testcase_11 AC 405 ms
14,920 KB
testcase_12 AC 427 ms
14,860 KB
testcase_13 AC 437 ms
14,896 KB
testcase_14 AC 397 ms
12,320 KB
testcase_15 AC 378 ms
10,780 KB
testcase_16 AC 374 ms
9,292 KB
testcase_17 AC 379 ms
9,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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