-
-
Save onemouth/5cc5c46c0f69e2aee04daeb0b7115548 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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