結果

問題 No.154 市バス
ユーザー konsin_tokage
提出日時 2018-06-06 12:16:54
言語 Haskell
(9.10.1)
結果
WA  
実行時間 -
コード長 495 bytes
コンパイル時間 2,015 ms
コンパイル使用メモリ 174,516 KB
実行使用メモリ 47,104 KB
最終ジャッジ日時 2024-06-30 10:14:11
合計ジャッジ時間 3,493 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 2 WA * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Control.Monad

solve s 
  | or [go w 0 0 s | w <- [1..3]] = "possoble"
  | otherwise                     = "impossible"
  where
    go w g r ('W':cs) | w /= 0 = go (w-1) (g+1) r cs
                      | g /= 0 = go w g r cs
    go w g r ('G':cs) | g /= 0 = go w (g-1) (r+1) cs
    go w g r ('R':cs) | r /= 0 = go w g (r-1) cs
    go 0 0 0 []                = True
    go _ _ _ _                 = False

main = do
  t <- readLn
  ss <- replicateM t getLine
  mapM_ (putStrLn . solve) ss
0