minke #5492(2008/01/27 17:17 GMT) [ Haskell ] Rating1/1=1.00
turn == True => 太郎のターン
turn == False => 花子のターン
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
import List import Control.Monad main :: IO () main = do n <- readLn c1 <- liftM sort $ sequence $ replicate n readLn let c2 = filter (`notElem` c1) [1..2*n] (a, b) = solve c1 c2 0 True mapM_ print [a, b] solve :: [Int] -> [Int] -> Int -> Bool -> (Int, Int) solve xs [] _ turn | turn = (0, length xs) -- Hanako won | otherwise = (length xs, 0) -- Taro won solve xs ys card turn = case break (card <) xs of (_, []) -> solve ys xs 0 (not turn) (small, x:big) -> solve ys (small++big) x (not turn)
Rating1/1=1.00-0+
[ reply ]
minke
#5492()
[
Haskell
]
Rating1/1=1.00
turn == True => 太郎のターン
turn == False => 花子のターン
Rating1/1=1.00-0+
[ reply ]