Skip to content

Instantly share code, notes, and snippets.

@onemouth
Last active June 20, 2018 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onemouth/5cc5c46c0f69e2aee04daeb0b7115548 to your computer and use it in GitHub Desktop.
Save onemouth/5cc5c46c0f69e2aee04daeb0b7115548 to your computer and use it in GitHub Desktop.
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)
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment