結果

問題 No.92 逃走経路
ユーザー ducktail
提出日時 2018-06-16 17:15:51
言語 Haskell
(9.10.1)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,162 bytes
コンパイル時間 813 ms
コンパイル使用メモリ 150,400 KB
最終ジャッジ日時 2024-06-30 16:18:04
合計ジャッジ時間 1,460 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、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:9:1: error: [GHC-87110]
    Could not load module ‘Data.Map’.
    It is a member of the hidden package ‘containers-0.6.8’.
    Use -v to see a list of the files searched for.
  |
9 | import Data.Map (Map)
  | ^^^^^^^^^^^^^^^^^^^^^

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

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
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ソースコード

diff #
プレゼンテーションモードにする

import Control.Applicative ((<$>), (<*>))
import Control.Monad (replicateM)
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List (unfoldr, foldl')
import Data.Char (isSpace)
import Data.Map (Map)
import qualified Data.Map as M
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
main :: IO ()
main = do
[n, m, _] <- f
solve n <$> replicateM m f <*> f >>= mapM_ putStrLn
where f = readil B.readInt <$> B.getLine
solve :: Int -> [[Int]] -> [Int] -> [String]
solve n fts fs = let ls = foldl' (g mp) (IS.fromList [1..n]) fs in [(show . IS.size) ls, (unwords . map show . IS.toList) ls]
where f mp [a, b, c] = M.insertWith (++) (a, c) [b] (M.insertWith (++) (b, c) [a] mp)
mp = foldl' f M.empty fts
g mp st d = IS.foldl' h IS.empty st
where h s p = case M.lookup (p, d) mp of
Just xs -> IS.union s (IS.fromList xs)
Nothing -> 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')
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0