結果
問題 | No.154 市バス |
ユーザー |
![]() |
提出日時 | 2017-01-21 14:19:50 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 476 ms / 2,000 ms |
コード長 | 505 bytes |
コンパイル時間 | 50 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 13,568 KB |
最終ジャッジ日時 | 2024-10-13 08:53:31 |
合計ジャッジ時間 | 4,032 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
コンパイルメッセージ
Syntax OK
ソースコード
T = gets.to_iS = T.times.map {gets.chomp}def f(s)r = 0g = 0w = 0s.reverse.each_char do |c|if c == "R"r += 1elsif c == "G"if r == 0return "impossible"elser -= 1g += 1endelsif c == "W"if g == 0 and w == 0return "impossible"elseg = [g - 1, 0].maxw += 1endendendif r == 0 and g == 0"possible"else"impossible"endendans = S.map {|s| f(s)}puts ans