結果
| 問題 |
No.1005 BOT対策
|
| コンテスト | |
| ユーザー |
brthyyjp
|
| 提出日時 | 2020-05-02 16:53:11 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 671 bytes |
| コンパイル時間 | 304 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 58,368 KB |
| 最終ジャッジ日時 | 2024-12-30 13:06:22 |
| 合計ジャッジ時間 | 2,925 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 WA * 3 |
ソースコード
s = str(input())
t = str(input())
if len(t) == 1:
if t in set(list(s)):
print(-1)
else:
print(0)
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)
brthyyjp