結果

問題 No.430 文字列検索
ユーザー 👑 yumechiyumechi
提出日時 2016-10-03 00:36:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 265 ms / 2,000 ms
コード長 371 bytes
コンパイル時間 840 ms
コンパイル使用メモリ 10,628 KB
実行使用メモリ 52,824 KB
最終ジャッジ日時 2023-08-15 17:33:30
合計ジャッジ時間 3,539 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,600 KB
testcase_01 AC 265 ms
52,704 KB
testcase_02 AC 151 ms
8,964 KB
testcase_03 AC 148 ms
8,940 KB
testcase_04 AC 15 ms
8,568 KB
testcase_05 AC 15 ms
8,468 KB
testcase_06 AC 15 ms
8,480 KB
testcase_07 AC 15 ms
8,456 KB
testcase_08 AC 257 ms
52,824 KB
testcase_09 AC 16 ms
8,436 KB
testcase_10 AC 35 ms
11,592 KB
testcase_11 AC 164 ms
14,236 KB
testcase_12 AC 167 ms
14,288 KB
testcase_13 AC 163 ms
14,212 KB
testcase_14 AC 157 ms
12,148 KB
testcase_15 AC 155 ms
11,348 KB
testcase_16 AC 149 ms
9,204 KB
testcase_17 AC 148 ms
9,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

def solve():
    s = input()
    slist = defaultdict(lambda: 0)
    slen = len(s)
    for i in range(1, 11):
        if i <= slen:
            for j in range(slen-i+1):
                slist[s[j:j+i]] += 1
    ans = 0
    for i in range(int(input())):
        ans += slist[input()]
    print(ans)

if __name__=="__main__":
    solve()
0