結果
問題 | No.157 2つの空洞 |
ユーザー | aimy |
提出日時 | 2017-04-26 18:58:25 |
言語 | Haskell (9.6.2) |
結果 |
AC
|
実行時間 | 212 ms / 2,000 ms |
コード長 | 600 bytes |
コンパイル時間 | 2,945 ms |
コンパイル使用メモリ | 166,984 KB |
実行使用メモリ | 12,100 KB |
最終ジャッジ日時 | 2023-10-11 14:00:15 |
合計ジャッジ時間 | 5,675 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
7,724 KB |
testcase_01 | AC | 2 ms
7,624 KB |
testcase_02 | AC | 3 ms
7,760 KB |
testcase_03 | AC | 3 ms
7,764 KB |
testcase_04 | AC | 3 ms
8,008 KB |
testcase_05 | AC | 4 ms
8,380 KB |
testcase_06 | AC | 2 ms
8,004 KB |
testcase_07 | AC | 3 ms
7,732 KB |
testcase_08 | AC | 3 ms
7,852 KB |
testcase_09 | AC | 4 ms
8,192 KB |
testcase_10 | AC | 2 ms
7,752 KB |
testcase_11 | AC | 3 ms
8,204 KB |
testcase_12 | AC | 3 ms
7,904 KB |
testcase_13 | AC | 3 ms
7,864 KB |
testcase_14 | AC | 112 ms
12,068 KB |
testcase_15 | AC | 32 ms
11,968 KB |
testcase_16 | AC | 22 ms
10,380 KB |
testcase_17 | AC | 212 ms
12,100 KB |
testcase_18 | AC | 4 ms
8,124 KB |
testcase_19 | AC | 3 ms
7,828 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
ソースコード
import qualified Data.Set as S import Data.List manhattan (x1,y1) (x2,y2) = abs (x1-x2) + abs (y1-y2) nub' = S.toList . S.fromList untilFix f x = if f x == x then x else untilFix f (f x) reachable ps p = untilFix move [p] where move = nub' . concatMap neighbor neighbor (x,y) = intersect [(x,y),(x+1,y),(x-1,y),(x,y+1),(x,y-1)] ps main = getContents >>= print . twohole . lines twohole (wh:m) = minimum (manhattan <$> h1 <*> h2) - 1 where [w,h] = map read (words wh) hs = [(x,y) | x<-[1..w-2], y<-[1..h-2], m!!y!!x == '.'] (h1,h2) = let hs' = reachable hs (head hs) in (hs', hs\\hs')