結果

問題 No.11 カードマッチ
ユーザー LeonardoneLeonardone
提出日時 2019-09-04 04:57:58
言語 Haskell
(9.8.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 741 bytes
コンパイル時間 815 ms
コンパイル使用メモリ 143,104 KB
最終ジャッジ日時 2023-12-27 10:47:56
合計ジャッジ時間 1,448 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、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:8:1: error:
    Could not load module ‘Data.Map’
    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.
  |
8 | import qualified Data.Map as Map
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ソースコード

diff #

--リジャッジでコンパイルエラー起こしていた
-- Map.foldがMap.foldrに変わったというエラーメッセージどおりに修正

-- yukicoder My Practice
-- author: Leonardone @ NEETSDKASU

import Data.List
import qualified Data.Map as Map

main = do
    w <- readLn
    h <- readLn
    n <- getLine
    sk <- getContents
    putStrLn $ solve w h n sk

solve w h n sk = show ans where
    (sm, km) = foldl fn (Map.empty, Map.empty) $ map words $ lines sk where
        fn (sm, km) (s:k:_) = (fx s sm, fx k km) where
            fx t tm = Map.insert t (case Map.lookup t tm of { Just x -> x + 1; _ -> 1 }) tm
    c1 = Map.foldr (\a b -> b + (h - a)) 0 sm
    c2 = (w - (Map.size sm)) * (Map.size km)
    ans = c1 + c2
0