結果

問題 No.154 市バス
ユーザー konsin_tokagekonsin_tokage
提出日時 2018-06-06 12:18:45
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 495 bytes
コンパイル時間 734 ms
コンパイル使用メモリ 166,508 KB
実行使用メモリ 50,328 KB
最終ジャッジ日時 2023-09-12 22:42:45
合計ジャッジ時間 2,638 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
6,956 KB
testcase_06 AC 3 ms
6,900 KB
testcase_07 WA -
testcase_08 AC 2 ms
7,000 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/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]] = "possible"
  | 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