結果

問題 No.430 文字列検索
ユーザー masatosismasatosis
提出日時 2022-05-12 13:22:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 940 ms / 2,000 ms
コード長 459 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 10,704 KB
実行使用メモリ 93,116 KB
最終ジャッジ日時 2023-09-27 12:38:11
合計ジャッジ時間 7,263 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,940 KB
testcase_01 AC 940 ms
93,116 KB
testcase_02 AC 405 ms
9,744 KB
testcase_03 AC 423 ms
9,612 KB
testcase_04 AC 18 ms
9,040 KB
testcase_05 AC 17 ms
8,984 KB
testcase_06 AC 18 ms
9,056 KB
testcase_07 AC 18 ms
9,004 KB
testcase_08 AC 913 ms
93,028 KB
testcase_09 AC 19 ms
8,916 KB
testcase_10 AC 96 ms
15,320 KB
testcase_11 AC 497 ms
20,276 KB
testcase_12 AC 508 ms
20,524 KB
testcase_13 AC 515 ms
20,524 KB
testcase_14 AC 467 ms
15,340 KB
testcase_15 AC 449 ms
13,436 KB
testcase_16 AC 392 ms
10,212 KB
testcase_17 AC 394 ms
9,700 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

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