結果

問題 No.24 数当てゲーム
ユーザー momen999momen999
提出日時 2017-06-15 14:25:44
言語 Haskell
(9.8.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 792 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 149,888 KB
最終ジャッジ日時 2024-04-27 02:26:43
合計ジャッジ時間 580 ms
ジャッジサーバーID
(参考情報)
judge1 / 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:2:1: error: [GHC-87110]
    Could not load module ‘Data.Set’.
    It is a member of the hidden package ‘containers-0.6.8’.
    Use -v to see a list of the files searched for.
  |
2 | import qualified Data.Set as S
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ソースコード

diff #

import Control.Monad
import qualified Data.Set as S

rInt :: String -> Int
rInt = read

iSet = S.singleton (-1)

solve xs yes no
    | length xs == 0            = head $ S.toList result
    | last (head xs) == "YES"   = solve (tail xs) yes' no
    | otherwise                 = solve (tail xs) yes no'
    where
        result  | yes == iSet   = S.difference (S.fromList [0..9]) no
                | otherwise     = S.difference yes no
        yes'    | yes == iSet   = xs'
                | otherwise     = S.difference yes (S.difference yes xs')
        no'     | no == iSet    = xs'
                | otherwise     = S.union no xs'
        xs' = S.fromList $ map (rInt) $ init $ head xs

main = do
    n <- readLn
    xs <- map words <$> replicateM n getLine
    print $ solve xs iSet iSet
0