結果
問題 | No.154 市バス |
ユーザー | aimy |
提出日時 | 2017-08-31 21:54:43 |
言語 | Haskell (9.8.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 675 bytes |
コンパイル時間 | 2,412 ms |
コンパイル使用メモリ | 175,104 KB |
実行使用メモリ | 8,192 KB |
最終ジャッジ日時 | 2024-04-21 10:22:55 |
合計ジャッジ時間 | 5,513 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 329 ms
8,192 KB |
testcase_01 | AC | 332 ms
8,064 KB |
testcase_02 | AC | 336 ms
8,064 KB |
testcase_03 | AC | 269 ms
7,936 KB |
testcase_04 | WA | - |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 306 ms
7,936 KB |
testcase_08 | AC | 2 ms
5,376 KB |
コンパイルメッセージ
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
ソースコード
import Data.Bool import Data.List last' s = if null s then "" else last s main = getLine >> interact (unlines . map (bool "impossible" "possible" . citybus) . lines) citybus s = and [num, restR, restG, pairGR] where num = let [g,r,w] = map (pred.length) (group (sort ("WGR"++s))) in g == r && w >= g restR = (=="R") $ last' $ filter (\(b:_) -> b=='R') $ delete [] $ tails s restG = (notElem 'W') $ last' $ filter (\(b:_) -> b=='G') $ delete [] $ tails s pairGR = foldr pairGRgo (Just 0) s == Just 0 pairGRgo _ Nothing = Nothing pairGRgo 'R' (Just n) = Just (n + 1) pairGRgo 'G' (Just n) | n == 0 = Nothing | otherwise = Just (n - 1) pairGRgo _ m = m