結果
問題 | 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_i S = T.times.map {gets.chomp} def f(s) r = 0 g = 0 w = 0 s.reverse.each_char do |c| if c == "R" r += 1 elsif c == "G" if r == 0 return "impossible" else r -= 1 g += 1 end elsif c == "W" if g == 0 and w == 0 return "impossible" else g = [g - 1, 0].max w += 1 end end end if r == 0 and g == 0 "possible" else "impossible" end end ans = S.map {|s| f(s)} puts ans