結果

問題 No.1005 BOT対策
コンテスト
ユーザー Mr.Fuku
提出日時 2020-07-14 13:21:42
言語 Ruby
(4.0.2)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
AC  
実行時間 53 ms / 2,000 ms
+ 873µs
コード長 303 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 25 ms
コンパイル使用メモリ 9,088 KB
実行使用メモリ 14,464 KB
最終ジャッジ日時 2026-07-12 08:28:42
合計ジャッジ時間 3,293 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:11: warning: ambiguous first argument; put parentheses or a space even after `-` operator
Syntax OK

ソースコード

diff #
raw source code

def is_impossible(s, t)
    return false if t.size > 1
    
    s.include?(t)
end

s = gets.chomp
t = gets.chomp

if is_impossible(s, t)
    puts -1
    return
end

cnt = 0
t_len = t.size

while true do
    idx = s.index(t)
    break if idx.nil?
    
    s = s[idx+t_len-1...]
    cnt += 1
end

puts cnt
0