結果

問題 No.1005 BOT対策
コンテスト
ユーザー Mr.Fuku
提出日時 2020-07-14 13:21:42
言語 Ruby
(4.0.9 + ACL)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
AC  
実行時間 65 ms / 2,000 ms
+ 274µs
コード長 303 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 13 ms
コンパイル使用メモリ 8,704 KB
実行使用メモリ 14,592 KB
最終ジャッジ日時 2026-11-06 00:48:30
合計ジャッジ時間 4,306 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます
コンパイルメッセージ
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