結果
問題 | No.548 国士無双 |
ユーザー | はむ吉🐹 |
提出日時 | 2017-07-30 19:01:13 |
言語 | Haskell (9.6.2) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 819 bytes |
コンパイル時間 | 5,570 ms |
コンパイル使用メモリ | 142,304 KB |
最終ジャッジ日時 | 2023-10-17 16:03:15 |
合計ジャッジ時間 | 5,992 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) Main.hs:1:1: error: Could not load module ‘Data.Map.Strict’ It is a member of the hidden package ‘containers-0.6.7’. You can run ‘:set -package containers’ to expose it. (Note: this unloads all the modules in the current scope.) Use -v (or `:set -v` in ghci) to see a list of the files searched for. | 1 | import qualified Data.Map.Strict as M | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
import qualified Data.Map.Strict as M type Count = Int type Counter a = M.Map a Count addElement :: Ord a => a -> Counter a -> Counter a addElement x = M.insertWith (+) x 1 buildCounter :: Ord a => [a] -> Counter a buildCounter = foldr addElement M.empty countElem :: Ord a => Counter a -> a -> Count countElem ctr el = M.findWithDefault 0 el ctr isKokushi :: Counter Char -> Bool isKokushi ctr = f 1 == 12 && f 2 == 1 && M.keys ctr == ['a' .. 'm'] where mctr = buildCounter $ M.elems ctr f = countElem mctr solve :: String -> [String] solve s = (: []) <$> filter g ['a' .. 'z'] where g c = isKokushi $ addElement c ctr ctr = buildCounter s main :: IO () main = do s <- getLine let res = solve s if null res then putStrLn "Impossible" else putStr $ unlines res