結果

問題 No.154 市バス
ユーザー tottoripapertottoripaper
提出日時 2015-03-04 17:58:43
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 570 bytes
コンパイル時間 2,481 ms
コンパイル使用メモリ 173,824 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2024-04-21 08:21:37
合計ジャッジ時間 2,622 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
8,192 KB
testcase_01 AC 45 ms
7,936 KB
testcase_02 AC 44 ms
8,064 KB
testcase_03 AC 32 ms
8,064 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 37 ms
7,936 KB
testcase_08 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

main = do
  n <- readLn
  replicateM n $ do
         s <- getLine
         let
             f [] g = g == 0
             f (x:xs) g
               | x == 'W' = f xs g
               | x == 'G' = f xs (g+1)
               | g > 0 = f xs (g-1)
               | otherwise = False
             sl = length s
             gn = length . filter (=='G') $ s
             rn = length . filter (=='R') $ s
          in putStrLn $ if gn == 0 || rn == 0 || gn /= rn || sl < gn * 3 || not (f s 0) then "impossible" else "possible"
                             
0