結果

問題 No.1005 BOT対策
ユーザー miya145592miya145592
提出日時 2023-05-19 01:35:23
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 702 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 71,672 KB
最終ジャッジ日時 2023-08-22 14:39:33
合計ジャッジ時間 5,245 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,672 KB
testcase_01 AC 70 ms
71,252 KB
testcase_02 AC 70 ms
71,264 KB
testcase_03 AC 70 ms
71,096 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# https://tjkendev.github.io/procon-library/python/string/z-algorithm.html
def z_algo(S):
    N = len(S)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A

S = input()
T = input()
z = z_algo(T+S)
cnt = 0
i = len(T)
while i<len(T)+len(S):
    if z[i]>=len(T):
        cnt += 1
        i+=len(T)-1
    else:
        i+=1
    
if len(T)==1:
    if cnt>0:
        print(-1)
    else:
        print(0)
else:
    print(cnt)
0