結果
問題 | No.154 市バス |
ユーザー |
|
提出日時 | 2018-09-13 15:57:24 |
言語 | Haskell (9.10.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 599 bytes |
コンパイル時間 | 1,790 ms |
コンパイル使用メモリ | 170,752 KB |
実行使用メモリ | 55,936 KB |
最終ジャッジ日時 | 2024-07-01 04:26:18 |
合計ジャッジ時間 | 4,568 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 1 |
other | AC * 8 |
コンパイルメッセージ
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
ソースコード
importControl.ApplicativeimportControl.MonadimportData.Boolboolmain::IO()main = don <- readLnmap solve <$> replicateM n getLine >>= mapM_ putStrLnsolve::String->Stringsolve bs = bool "impossible" "possible" $ last bs == 'R' && last (filter (/= 'R') bs) == 'G' && f (0, 0) bswheref (_, g) [] = g == 0f (w, g) (b:bs)| b == 'R' = if g > 0then f (w, g - 1) bselse False| b == 'G' = if w > 0then f (w - 1, g + 1) bselse False| otherwise = f (w + 1, g) bs