結果

問題 No.1005 BOT対策
ユーザー brthyyjpbrthyyjp
提出日時 2020-05-02 16:51:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 614 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 87,336 KB
実行使用メモリ 75,996 KB
最終ジャッジ日時 2023-08-28 22:32:21
合計ジャッジ時間 4,744 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,240 KB
testcase_01 AC 71 ms
71,428 KB
testcase_02 AC 73 ms
71,460 KB
testcase_03 AC 75 ms
71,404 KB
testcase_04 AC 72 ms
71,160 KB
testcase_05 AC 74 ms
70,968 KB
testcase_06 AC 73 ms
71,312 KB
testcase_07 AC 73 ms
71,200 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 74 ms
71,248 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 73 ms
71,436 KB
testcase_14 AC 78 ms
71,140 KB
testcase_15 AC 74 ms
71,408 KB
testcase_16 AC 74 ms
71,352 KB
testcase_17 AC 74 ms
71,308 KB
testcase_18 WA -
testcase_19 AC 72 ms
71,184 KB
testcase_20 AC 72 ms
71,212 KB
testcase_21 AC 79 ms
75,996 KB
testcase_22 AC 76 ms
75,908 KB
testcase_23 AC 72 ms
71,200 KB
testcase_24 AC 76 ms
71,108 KB
testcase_25 AC 75 ms
70,964 KB
testcase_26 AC 74 ms
71,204 KB
testcase_27 AC 72 ms
71,436 KB
testcase_28 WA -
testcase_29 AC 73 ms
71,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = str(input())
t = str(input())

if len(t) == 1:
    print(-1)
    exit()

def z_algorithm(s):
    n = len(s)
    Z = [0]*n
    Z[0] = n
    i = 1
    j = 0
    while i < n:
        while i+j < n and s[j] == s[i+j]:
            j += 1
        Z[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i+k < n and k+Z[k] < j:
            Z[i+k] = Z[k]
            k += 1
        i += k
        j -= k
    return Z

Z = z_algorithm(t+s)
#print(Z)
ans = 0
i = 1
while i < len(Z):
    if Z[i] >= len(t):
        ans += 1
        i += len(t)
    else:
        i += 1

print(ans)
0