結果

問題 No.133 カードゲーム
ユーザー alpha_virginisalpha_virginis
提出日時 2017-02-19 02:25:40
言語 Haskell
(9.8.2)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 1,353 bytes
コンパイル時間 6,517 ms
コンパイル使用メモリ 163,116 KB
実行使用メモリ 7,892 KB
最終ジャッジ日時 2023-09-07 09:30:54
合計ジャッジ時間 7,635 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,500 KB
testcase_01 AC 3 ms
7,616 KB
testcase_02 AC 3 ms
7,492 KB
testcase_03 AC 3 ms
7,176 KB
testcase_04 AC 3 ms
7,652 KB
testcase_05 AC 3 ms
7,720 KB
testcase_06 AC 4 ms
7,704 KB
testcase_07 AC 4 ms
7,764 KB
testcase_08 AC 3 ms
7,524 KB
testcase_09 AC 3 ms
7,500 KB
testcase_10 AC 3 ms
7,760 KB
testcase_11 AC 3 ms
7,780 KB
testcase_12 AC 3 ms
7,788 KB
testcase_13 AC 3 ms
7,612 KB
testcase_14 AC 3 ms
7,484 KB
testcase_15 AC 2 ms
7,556 KB
testcase_16 AC 3 ms
7,776 KB
testcase_17 AC 3 ms
7,464 KB
testcase_18 AC 3 ms
7,768 KB
testcase_19 AC 3 ms
7,756 KB
testcase_20 AC 3 ms
7,892 KB
testcase_21 AC 3 ms
7,768 KB
testcase_22 AC 3 ms
7,760 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

{-# LANGUAGE OverloadedStrings #-}
module Main where

import Data.Maybe
import qualified Data.ByteString.Char8 as C
import Control.Monad(forM_)
import Data.Int
import Data.List
import Data.Array
import Data.Word
import Data.Bits
import qualified Data.IntMap as IntMap
import qualified Data.Map as Map

yes :: C.ByteString
yes = "YES"

no :: C.ByteString
no = "NO"

getInts :: IO [Int]
getInts = do
  ss <- C.getLine
  return $ map (fst . fromJust . C.readInt) $ C.words ss

getIntss :: Int -> IO [[Int]]
getIntss 0 = return []
getIntss n = do
  xs <- getInts
  xss <- getIntss (n - 1)  
  return $ xs : xss

-- end standard template --

main :: IO ()
main = do
  [n] <- getInts
  xs <- getInts
  ys <- getInts
  let res = solve n xs ys
  print res

solve :: Int -> [Int] -> [Int] -> Double
solve n xs ys = (sum $ map eval zs) / (realToFrac $ length zs)
  where
    zs = [zip xs' ys' | xs' <- permutations xs, ys' <- permutations ys]
    eval :: [(Int,Int)] -> Double
    eval ws = let (s1, s2) = eval' ws (0,0) in if s1 > s2 then 1.0 else 0.0
    eval' :: [(Int,Int)] -> (Int, Int) -> (Int, Int)
    eval' [] t = t
    eval' ((w1,w2):ws) (s1, s2) = case compare w1 w2 of
                                  LT -> eval' ws (s1, s2 + 1)
                                  EQ -> eval' ws (s1, s2)
                                  GT -> eval' ws (s1 + 1, s2)
0