結果

問題 No.1005 BOT対策
ユーザー lam6er
提出日時 2025-03-31 17:19:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 667 bytes
コンパイル時間 424 ms
コンパイル使用メモリ 82,628 KB
実行使用メモリ 54,688 KB
最終ジャッジ日時 2025-03-31 17:19:43
合計ジャッジ時間 2,466 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input().strip()
t = input().strip()

m = len(t)
n = len(s)

if m == 0 or n < m:
    print(0)
    exit()

intervals = []
for i in range(n - m + 1):
    substr = s[i:i+m]
    if substr == t:
        start = i
        end = i + m - 1
        intervals.append((start, end))

if not intervals:
    print(0)
else:
    # Sort intervals by their end positions
    intervals.sort(key=lambda x: x[1])
    count = 0
    last_point = -1  # Tracks the last position where a '.' was inserted
    for start, end in intervals:
        if start > last_point:
            count += 1
            last_point = end  # Insert '.' at the end of this interval to break T
    print(count)
0