結果

問題 No.380 悪の台本
ユーザー koba-e964koba-e964
提出日時 2016-12-06 20:35:44
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 759 bytes
コンパイル時間 37 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-04-24 14:52:06
合計ジャッジ時間 1,824 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
12,160 KB
testcase_01 RE -
testcase_02 AC 91 ms
12,288 KB
testcase_03 AC 88 ms
12,032 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 308 ms
12,160 KB
testcase_08 RE -
testcase_09 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def search(s, t)
  if s.size < t.size
    return false
  end
  for i in 0 .. [3, s.size - t.size].min
    if s[-t.size-i..-1-i] == t
      return true
    end
  end
  false
end


while true
  s = gets
  if s.nil?
    exit 0
  end
  s = s.chomp
  ok = false
  if s[0..4] == "digi "
    ok = search(s.downcase[5..-1], "nyo")
  end
  if s[0..5] == "petit "
    ok = search(s.downcase[6..-1], "nyu")
  end
  if s[0..4] == "gema "
    ok = search(s.downcase[5..-1], "gema")
  end
  if s[0..4] == "piyo "
    ok = search(s[5..-1].downcase, "pyo")
  end
  if s[0..4] == "rabi "
    t = s[5..-1].downcase
    for k in t
      if ('0' <= k && k <= '9') || ('a' <= k && k <= 'z')
        ok = true
      end
    end
  end
  puts (ok ? "CORRECT (maybe)" : "WRONG!")
end
0