結果

問題 No.452 横着者のビンゴゲーム
ユーザー okadukiokaduki
提出日時 2016-12-12 02:43:19
言語 Haskell
(9.8.2)
結果
AC  
実行時間 2,211 ms / 3,000 ms
コード長 1,237 bytes
コンパイル時間 6,982 ms
コンパイル使用メモリ 182,488 KB
実行使用メモリ 21,472 KB
最終ジャッジ日時 2023-08-19 18:34:48
合計ジャッジ時間 24,374 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,488 KB
testcase_01 AC 3 ms
7,604 KB
testcase_02 AC 2 ms
7,720 KB
testcase_03 AC 12 ms
11,632 KB
testcase_04 AC 4 ms
8,184 KB
testcase_05 AC 12 ms
11,740 KB
testcase_06 AC 2 ms
7,672 KB
testcase_07 AC 4 ms
9,068 KB
testcase_08 AC 7 ms
11,676 KB
testcase_09 AC 3 ms
7,636 KB
testcase_10 AC 3 ms
8,124 KB
testcase_11 AC 6 ms
10,668 KB
testcase_12 AC 4 ms
8,196 KB
testcase_13 AC 2 ms
7,496 KB
testcase_14 AC 392 ms
21,472 KB
testcase_15 AC 322 ms
21,376 KB
testcase_16 AC 293 ms
16,556 KB
testcase_17 AC 82 ms
11,864 KB
testcase_18 AC 212 ms
12,604 KB
testcase_19 AC 142 ms
12,136 KB
testcase_20 AC 102 ms
12,084 KB
testcase_21 AC 502 ms
13,672 KB
testcase_22 AC 72 ms
12,040 KB
testcase_23 AC 923 ms
14,656 KB
testcase_24 AC 72 ms
11,808 KB
testcase_25 AC 32 ms
11,800 KB
testcase_26 AC 562 ms
14,284 KB
testcase_27 AC 373 ms
12,572 KB
testcase_28 AC 242 ms
12,732 KB
testcase_29 AC 152 ms
12,196 KB
testcase_30 AC 652 ms
14,296 KB
testcase_31 AC 102 ms
12,256 KB
testcase_32 AC 72 ms
11,928 KB
testcase_33 AC 273 ms
12,336 KB
testcase_34 AC 242 ms
12,644 KB
testcase_35 AC 172 ms
12,180 KB
testcase_36 AC 42 ms
11,776 KB
testcase_37 AC 52 ms
11,736 KB
testcase_38 AC 2,211 ms
19,332 KB
testcase_39 AC 1,482 ms
16,376 KB
testcase_40 AC 1,483 ms
16,364 KB
testcase_41 AC 1,472 ms
16,292 KB
testcase_42 AC 1,472 ms
16,336 KB
testcase_43 AC 1,482 ms
16,404 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 #

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 qualified Data.Set as S

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 = S.fromList [arr!(m,y,x) | y <- [1..n]]
getRow arr n m y = S.fromList [arr!(m,y,x) | x <- [1..n]]
getDiag arr n m = [S.fromList [arr!(m,i,i) | i <- [1..n]], S.fromList [arr!(m,n+1-i,i) | i <- [1..n]]]

calc ss n m1 m2 = minimum [S.size (S.union s1 s2) |
                           s1 <- ss!m1,
                           s2 <- ss!m2]

build arr n m = [(i,xs) | i <- [1..m],
                  let xs = [getCol arr n i x | x <- [1..n]]
                           ++ [getRow arr n i y | y <- [1..n]]
                           ++ getDiag arr n i]

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 ss = array (1,m) $ build arr n m
  let ans = minimum [calc ss n m1 m2 | m1 <- [1..m], m2 <- [m1+1..m]]
  print $ ans-1
0