結果
| 問題 |
No.183 たのしい排他的論理和(EASY)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-08-02 21:44:42 |
| 言語 | Haskell (9.10.1) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 773 bytes |
| コンパイル時間 | 210 ms |
| コンパイル使用メモリ | 148,992 KB |
| 最終ジャッジ日時 | 2024-07-01 03:34:13 |
| 合計ジャッジ時間 | 553 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、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:12: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.
|
12 | import Data.IntSet (IntSet)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Main.hs:13: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.
|
13 | import qualified Data.IntSet as IS
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
import Control.Applicative ((<$>))
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List (unfoldr)
import Data.List (foldl')
import Data.Char (isSpace)
import Data.Bits (xor)
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
main :: IO ()
main = do
getLine
solve <$> readil B.readInt <$> B.getLine >>= print
solve :: [Int] -> Int
solve = IS.size . foldl' f (IS.singleton 0)
where f ns x | IS.notMember x ns = IS.foldl g ns ns
| otherwise = ns
where g s k = IS.insert (k `xor` x) s
readil :: Integral a => (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a]
readil f = unfoldr g
where
g s = do
(n, s') <- f s
return (n, B.dropWhile isSpace s')