Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uis_tsai@tw-louistsai2:~
- import Data.Function ((&))
- import Data.Map (Map)
- import qualified Data.Map as Map
- import System.IO
- import Control.Monad
- testOnePair :: (Ord k, Eq a) => (k, a) -> Map k a -> (Bool, Map k a)
- testOnePair (k,v) table =
- case (Map.lookup k table)
- of Nothing -> (True, Map.insert k v table)
- Just v'-> if (v == v') then (True, table)
- else (False, table)
- testFunction [] table = True
- testFunction ((k,v):lst) table =
- case testOnePair (k,v) table
- of (False, _) -> False
- (True, table') -> testFunction lst table'
- _main = do
- nLine <- readLn :: IO Int
- replicateM_ nLine $ return ()
- main = do
- nTestCase <- readLn :: IO Int
- replicateM_ nTestCase _main
- --forM_ [1..nTestCase] $ \_ -> _main
- --print $ show (nTestCase :: Int)
- ~
Add Comment
Please, Sign In to add comment