結果

問題 No.345 最小チワワ問題
ユーザー m
提出日時 2020-08-09 06:12:58
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 327 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-10-03 08:10:42
合計ジャッジ時間 4,447 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:22: 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"
    c = i
  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