結果

問題 No.345 最小チワワ問題
ユーザー m
提出日時 2020-08-09 06:15:12
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 352 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-10-03 08:15:06
合計ジャッジ時間 4,551 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 14
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:24: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

s = gets.chomp.split("")
c, w1, w2 = -1, -1, -1
s.each_with_index {|x, i|
  case x
  when "c"
    if c == -1
      c = i
    end
  when "w"
    if c != -1
      if w1 == -1
        w1 = i
      else
        if w2 == -1
          w2 = i
        end
      end
    end
  end
}
if c == -1 ||
   w1 == -1 ||
   w2 == -1
  puts -1
else
  puts w2 - c + 1
end
0