結果
| 問題 |
No.430 文字列検索
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-11-21 14:15:54 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 722 bytes |
| コンパイル時間 | 209 ms |
| コンパイル使用メモリ | 82,560 KB |
| 実行使用メモリ | 82,304 KB |
| 最終ジャッジ日時 | 2024-11-10 00:38:16 |
| 合計ジャッジ時間 | 3,619 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 4 |
| other | AC * 1 TLE * 1 -- * 12 |
ソースコード
from collections import defaultdict
def get_input():
s = str(input())
m = int(input())
c = [str(input()) for i in range(m)]
return s, m, c
if __name__ == "__main__":
s, m, c = get_input()
count = 0
s_id = defaultdict(lambda:len(s_id)+1)
for ci in c:
len_c = len(ci)
first, target = 0, 0
for i in range(len_c):
target += s_id[ci[i]] * 10**(len_c - i - 1)
first += s_id[s[i]] * 10**(len_c - i - 1)
if first == target:
count += 1
for i in range(len_c,len(s)):
first = (first % 10**(len_c -1 )) * 10 + s_id[s[i]]
if target == first:
count += 1
print(count)