結果

問題 No.11 カードマッチ
ユーザー 情報学生情報学生
提出日時 2019-08-27 00:07:43
言語 Haskell
(9.8.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 954 bytes
コンパイル時間 4,327 ms
コンパイル使用メモリ 143,488 KB
最終ジャッジ日時 2023-11-25 16:53:47
合計ジャッジ時間 4,832 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、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:10:1: error:
    Could not load module ‘Data.IntSet’
    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.
   |
10 | import Data.IntSet (IntSet)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^

Main.hs:11:1: error:
    Could not load module ‘Data.IntSet’
    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.
   |
11 | import qualified Data.IntSet as ISet
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ソースコード

diff #

import Control.Applicative ((<$>))
import Control.Monad (replicateM)
import Data.Bits (xor)

import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B

import Data.Char (isSpace)

import Data.IntSet (IntSet)
import qualified Data.IntSet as ISet

import Data.List (foldl', unfoldr, nub)


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]] -> Int
solve w h n xss = xs * h + ys * w - xs * ys - n
    where
        xs = length $ nub $ map head xss
        ys = length $ nub $ map (head.tail) xss
0