結果

問題 No.430 文字列検索
ユーザー PhysicsKJ
提出日時 2017-07-02 16:36:18
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 668 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-11-10 00:16:05
合計ジャッジ時間 9,273 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 8 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter


S = input()
M = int(input())
C = []
for i in range(M):
    C.append(input())


def search(C, S, flg):
    count = 0
    lenS = len(S)
    lenC = len(C)
    if flg == 1:
        while S.find(C) != -1:
            S = S[S.find(C)+1:]
            count += 1
        return count
    else:
        while S.find(C) != -1:
            S = S[S.find(C)+lenC:]
            count += 1
        return count

count = 0
for i in range(M):
    CC = C[i]
    flg = 1
    for j in range(len(CC)):
        if j == 0:
            continue
        if CC[j] != CC[j-1]:
            flg = 0
            break
    count += search(C[i], S, flg)
print(count)
0