結果
問題 | No.154 市バス |
ユーザー | ducktail |
提出日時 | 2018-09-13 15:57:24 |
言語 | Haskell (9.8.2) |
結果 |
RE
|
実行時間 | - |
コード長 | 599 bytes |
コンパイル時間 | 696 ms |
コンパイル使用メモリ | 162,880 KB |
実行使用メモリ | 58,444 KB |
最終ジャッジ日時 | 2023-09-13 19:53:56 |
合計ジャッジ時間 | 2,955 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 212 ms
58,400 KB |
testcase_01 | AC | 213 ms
58,376 KB |
testcase_02 | AC | 213 ms
58,444 KB |
testcase_03 | AC | 202 ms
57,348 KB |
testcase_04 | AC | 212 ms
58,356 KB |
testcase_05 | AC | 3 ms
6,908 KB |
testcase_06 | AC | 2 ms
6,916 KB |
testcase_07 | AC | 223 ms
58,332 KB |
testcase_08 | RE | - |
コンパイルメッセージ
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
ソースコード
import Control.Applicative import Control.Monad import Data.Bool (bool) main :: IO () main = do n <- readLn map solve <$> replicateM n getLine >>= mapM_ putStrLn solve :: String -> String solve bs = bool "impossible" "possible" $ last bs == 'R' && last (filter (/= 'R') bs) == 'G' && f (0, 0) bs where f (_, g) [] = g == 0 f (w, g) (b:bs) | b == 'R' = if g > 0 then f (w, g - 1) bs else False | b == 'G' = if w > 0 then f (w - 1, g + 1) bs else False | otherwise = f (w + 1, g) bs