結果

問題 No.2920 Blood Type
ユーザー tomcat1233tomcat1233
提出日時 2024-10-12 14:53:10
言語 Haskell
(9.8.2)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,329 bytes
コンパイル時間 9,579 ms
コンパイル使用メモリ 179,072 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-12 14:53:24
合計ジャッジ時間 10,717 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,820 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 1 ms
6,820 KB
testcase_03 AC 2 ms
6,816 KB
testcase_04 AC 2 ms
6,816 KB
testcase_05 AC 1 ms
6,820 KB
testcase_06 AC 1 ms
6,820 KB
testcase_07 AC 2 ms
6,816 KB
testcase_08 AC 2 ms
6,816 KB
testcase_09 AC 1 ms
6,816 KB
testcase_10 AC 2 ms
6,820 KB
testcase_11 AC 1 ms
6,820 KB
testcase_12 AC 1 ms
6,820 KB
testcase_13 AC 2 ms
6,824 KB
testcase_14 AC 2 ms
6,816 KB
testcase_15 AC 2 ms
6,816 KB
testcase_16 AC 1 ms
6,816 KB
testcase_17 AC 1 ms
6,816 KB
testcase_18 AC 2 ms
6,820 KB
testcase_19 AC 1 ms
6,816 KB
testcase_20 AC 1 ms
6,820 KB
testcase_21 AC 1 ms
6,816 KB
testcase_22 AC 1 ms
6,816 KB
testcase_23 AC 2 ms
6,820 KB
testcase_24 AC 1 ms
6,820 KB
testcase_25 AC 2 ms
6,816 KB
testcase_26 AC 1 ms
6,816 KB
testcase_27 AC 2 ms
6,820 KB
testcase_28 AC 1 ms
6,816 KB
testcase_29 AC 1 ms
6,816 KB
testcase_30 AC 1 ms
6,820 KB
testcase_31 AC 2 ms
6,816 KB
testcase_32 AC 1 ms
6,816 KB
testcase_33 AC 1 ms
6,816 KB
testcase_34 AC 2 ms
6,816 KB
testcase_35 AC 1 ms
6,816 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )

Main.hs:54:14: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘head’
    (imported from Data.List, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
   |
54 | nubOrd = map head.group.sort
   |              ^^^^
[2 of 2] Linking a.out

ソースコード

diff #

import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Control.Monad.ST             
import Data.Ix
import Data.Array (Array)
import Data.Array.IArray
import Data.Array.IO             
import Data.Array.MArray          
import Data.Array.ST                
import Data.Array.Unboxed (UArray)
import Data.Char
import Data.List as L

import Data.Foldable
import Control.Exception
import Data.Array.Base (STUArray(STUArray), UArray (UArray))
import Data.ByteString.Char8 (ByteString)
import Data.Array.IO.Internals (IOUArray(IOUArray))
import Data.Ord (comparing, Down (Down))
tuplify2 :: [b] -> (b, b)
tuplify2 (x:y:_) = (x,y)
tuplify2 _ = undefined

--Input functions with ByteString
readInt :: ByteString -> Int
readInt = fst . fromJust . BS.readInt
readIntTuple :: ByteString -> (Int, Int)
readIntTuple = tuplify2 . map readInt . BS.words
readIntList :: ByteString -> [Int]
readIntList = map readInt . BS.words

getInt :: IO Int
getInt = readInt <$> BS.getLine
getIntList :: IO [Int]
getIntList = readIntList <$> BS.getLine
getIntListX :: IO [Int]
getIntListX = readIntList <$> BS.getContents
getIntNList :: Integral a => a -> IO [[Int]]
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine
getIntMatrix :: IO [[Int]]
getIntMatrix = map readIntList . BS.lines <$> BS.getContents
getIntTuple :: IO (Int, Int)
getIntTuple = readIntTuple <$> BS.getLine
getIntNTuples :: Integral a => a -> IO [(Int, Int)]
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BS.getLine
getIntTuples :: IO [(Int, Int)]
getIntTuples = map readIntTuple . BS.lines <$> BS.getContents
putYesNo :: Bool -> IO ()
putYesNo bl = putStrLn $ if bl then "Yes" else "No"
putInts :: [Int] -> IO ()
putInts x = putStrLn $ unwords $ map show x
nubOrd :: Eq a => Ord a => [a] -> [a]
nubOrd = map head.group.sort

abo :: String -> String
abo blo
  | b == "AA" = "A"
  | b == "AB" = "AB"
  | b == "AO" = "A"
  | b == "BB" = "B"
  | b == "BO" = "B"
  | otherwise = "O"
  where b = sort blo


pro bls = [a, b, ab, o]
  where p x = length  (filter (==x) bls) * 100 `div` 4
        a = p "A"
        b = p "B"
        ab = p "AB"
        o = p "O"

main :: IO ()
main = do
  s <- getLine
  t <- getLine
  let st = (\ x y -> [x,y]) <$> s <*> t
  let bls = map abo st
  let ans = pro bls
  putInts ans
0