You are viewing a single comment's thread. Return to all comments →
the code using the trick Data.Map passed all test cases...XD
import qualified Data.Map.Strict as M; import Control.Monad; buildList [] = [] buildList (x:y:xs) = (x, y) : buildList xs backToList [] = [] backToList ((k,v):xs) = [k, v] ++ (backToList xs) buildMap :: Ord a => [a] -> M.Map a a buildMap = M.fromList . buildList main = do n <- read <$> getLine :: IO Int lines <- map (map read . words) <$> replicateM n getLine :: IO [[Int]] let maps = map buildMap lines res = foldr (M.intersectionWith min) (head maps) maps putStrLn . unwords . map show . backToList . M.toList $ res
Seems like cookies are disabled on this browser, please enable them to open this website
Lists and GCD
You are viewing a single comment's thread. Return to all comments →
the code using the trick Data.Map passed all test cases...XD