結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
12,160 KB
testcase_01 AC 92 ms
12,288 KB
testcase_02 AC 92 ms
12,160 KB
testcase_03 AC 90 ms
12,288 KB
testcase_04 AC 119 ms
13,440 KB
testcase_05 AC 145 ms
12,288 KB
testcase_06 AC 122 ms
12,416 KB
testcase_07 AC 305 ms
12,544 KB
testcase_08 AC 161 ms
20,608 KB
testcase_09 AC 112 ms
13,184 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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
    ch = s[-i].downcase
    if i >= 1 && (('0' <= ch && ch <= '9') || ('a' <= ch && ch <= 'z'))
      return false
    end
    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.chars
      if ('0' <= k && k <= '9') || ('a' <= k && k <= 'z')
        ok = true
      end
    end
  end
  puts (ok ? "CORRECT (maybe)" : "WRONG!")
end
0