結果

問題 No.11 カードマッチ
ユーザー 佐藤淳平佐藤淳平
提出日時 2019-09-11 12:55:01
言語 Haskell
(9.8.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 963 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 152,660 KB
最終ジャッジ日時 2024-04-27 04:57:40
合計ジャッジ時間 408 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )

Main.hs:5:1: error: [GHC-87110]
    Could not load module ‘Data.IntSet’.
    It is a member of the hidden package ‘containers-0.6.8’.
    Use -v to see a list of the files searched for.
  |
5 | import Data.IntSet (IntSet)
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^

Main.hs:6:1: error: [GHC-87110]
    Could not load module ‘Data.IntSet’.
    It is a member of the hidden package ‘containers-0.6.8’.
    Use -v to see a list of the files searched for.
  |
6 | import qualified Data.IntSet as IntSet
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ソースコード

diff #

import Control.Applicative ((<$>))
import Control.Monad (replicateM)
import Data.List (unfoldr)
import Data.Char (isSpace)
import Data.IntSet (IntSet)
import qualified Data.IntSet as IntSet
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B

getL :: (ByteString -> [Int]) -> IO [Int]
getL f = f <$> B.getLine

readIL :: (ByteString -> Maybe (Int, ByteString)) -> (ByteString -> [Int])
readIL f = unfoldr g
    where
        g s = do
            (n, s') <- f s
            return (n, B.dropWhile isSpace s')

main :: IO ()
main = do
    w <- readLn :: IO Int
    h <- readLn :: IO Int
    n <- readLn :: IO Int
    xss <- replicateM n $ getL (readIL B.readInt)
    print =<< solve w h n xss

solve :: Int -> Int -> Int -> [[Int]] -> IO Int
solve w h n xss = do
    let nxs = IntSet.size $ IntSet.fromList $ map head xss
        nys = IntSet.size $ IntSet.fromList $ map last xss
    return $ w * h  - ((w - nxs) * (h - nys) + n) 
0