結果
問題 |
No.154 市バス
|
ユーザー |
👑 |
提出日時 | 2020-04-11 21:56:48 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 702 bytes |
コンパイル時間 | 61 ms |
コンパイル使用メモリ | 5,376 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-19 14:02:39 |
合計ジャッジ時間 | 1,256 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
local q = io.read("*n", "*l") for iq = 1, q do local s = io.read() local red, green = 0, 0 local wcnt = 0 local rcnt = 0 local valid = true for i = #s, 1, -1 do local w = s:sub(i, i) if w == "R" then rcnt = rcnt + 1 red = red + 1 elseif w == "G" then if red == 0 then valid = false break else red = red - 1 green = green + 1 end else if green == 0 then if wcnt == 0 then valid = false break end else green = green - 1 wcnt = wcnt + 1 end end end if wcnt < rcnt then valid = false end print(valid and "possible" or "impossible") end