結果
| 問題 | No.1005 BOT対策 |
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 20:49:25 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 25 ms / 2,000 ms |
| + 974µs | |
| コード長 | 861 bytes |
| 記録 | |
| コンパイル時間 | 63 ms |
| コンパイル使用メモリ | 81,152 KB |
| 実行使用メモリ | 56,464 KB |
| 最終ジャッジ日時 | 2026-10-12 11:22:08 |
| 合計ジャッジ時間 | 2,470 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
S = input().strip()
T = input().strip()
m = len(T)
n = len(S)
if m == 1:
if T in S:
print(-1)
else:
print(0)
else:
# Find all occurrences of T in S
occurrences = []
t_len = len(T)
for i in range(len(S) - t_len + 1):
if S[i:i+t_len] == T:
occurrences.append(i)
if not occurrences:
print(0)
else:
# Generate intervals [i, i + m - 2]
intervals = []
for i in occurrences:
end = i + m - 2
intervals.append((i, end))
# Sort intervals by their end
intervals.sort(key=lambda x: x[1])
# Greedy interval covering
count = 0
last = -1
for start, end in intervals:
if start > last:
count += 1
last = end
print(count)
lam6er