結果

問題 No.452 横着者のビンゴゲーム
ユーザー okaduki
提出日時 2016-12-12 02:03:34
言語 Haskell
(9.10.1)
結果
WA  
実行時間 -
コード長 956 bytes
コンパイル時間 5,633 ms
コンパイル使用メモリ 180,312 KB
実行使用メモリ 18,176 KB
最終ジャッジ日時 2024-11-29 12:27:34
合計ジャッジ時間 65,861 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 2 TLE * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Data.Array
import Text.Printf
import Debug.Trace
import Data.List(union)

readInts :: B.ByteString -> [Int]
readInts = map (fst . fromJust . B.readInt) . B.words

getInts :: IO [Int]
getInts = liftM readInts B.getLine

getCol arr n m x = [arr!(m,y,x) | y <- [1..n]]
getRow arr n m y = [arr!(m,y,x) | x <- [1..n]]

calc arr n m1 m2 = minimum [length (union xs ys) | xs <- [getCol arr n m1 x | x <- [1..n]]++[getRow arr n m1 y | y <- [1..n]],
                            ys <- [getCol arr n m2 x | x <- [1..n]]++[getRow arr n m2 y | y <- [1..n]]]

main = do
  [n,m] <- getInts
  arr <- array ((1,1,1),(m,n,n)) <$> concat <$>
    forM [1..m] (\k -> concat <$>
                       forM [1..n] (\i -> zip [(k,i,j) | j <- [1..n]] <$> getInts))
  let ans = minimum [calc arr n m1 m2 | m1 <- [1..m], m2 <- [m1+1..m]]
  print $ ans-1
0