結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
![]() |
提出日時 | 2019-01-27 16:36:38 |
言語 | Ruby (3.4.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 615 bytes |
コンパイル時間 | 203 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,416 KB |
最終ジャッジ日時 | 2024-09-24 17:46:08 |
合計ジャッジ時間 | 4,548 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 RE * 1 |
other | AC * 21 RE * 8 |
コンパイルメッセージ
Syntax OK
ソースコード
strs = gets.chomp.scan(/c.*w.*w/) if strs.length == 0 puts "-1" else chars = strs[0].chars max = chars.length - 1 w1,w2 = false,false res = [] count = 1 0.step(max) do |i| next if chars[i] != "c" (i + 1).step(max) do |j| count += 1 if chars[j] == "w" and not w1 w1 = true elsif chars[j] == "w" and w1 w2 = true end if w1 and w2 res << count break end end count = 1 w1,w2 = false , false end end puts res.min