結果

問題 No.154 市バス
ユーザー tottoripapertottoripaper
提出日時 2015-03-04 18:09:42
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 616 bytes
コンパイル時間 2,472 ms
コンパイル使用メモリ 171,776 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2024-04-21 08:21:48
合計ジャッジ時間 3,593 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
8,192 KB
testcase_01 AC 69 ms
8,064 KB
testcase_02 AC 70 ms
8,064 KB
testcase_03 AC 41 ms
8,192 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 57 ms
8,064 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 [] w g = g == 0
             f (x:xs) w g
               | x == 'W' = f xs (w+1) g
               | x == 'G' = f xs w (g+1)
               | w > 0 && g > 0 = f xs (w-1) (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 || last s == 'W' || not (f s 0 0) then "impossible" else "possible"
                             
0