結果

問題 No.13 囲みたい!
ユーザー aimyaimy
提出日時 2017-05-10 17:11:51
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 532 bytes
コンパイル時間 12,240 ms
コンパイル使用メモリ 163,920 KB
実行使用メモリ 15,028 KB
最終ジャッジ日時 2023-10-13 10:03:43
合計ジャッジ時間 27,109 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,236 KB
testcase_01 AC 3 ms
7,256 KB
testcase_02 AC 3 ms
7,256 KB
testcase_03 AC 1,613 ms
14,164 KB
testcase_04 AC 4,082 ms
13,996 KB
testcase_05 AC 1,703 ms
14,172 KB
testcase_06 WA -
testcase_07 AC 2,643 ms
14,216 KB
testcase_08 AC 102 ms
14,128 KB
testcase_09 WA -
testcase_10 AC 23 ms
11,544 KB
testcase_11 AC 72 ms
13,360 KB
testcase_12 AC 12 ms
11,032 KB
testcase_13 AC 32 ms
12,096 KB
testcase_14 AC 32 ms
12,216 KB
testcase_15 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 #

import Data.Bool
import Data.List
import qualified Data.Set as S

main = do
 [w,h] <- map read . words <$> getLine
 ms <- map read . words <$> getContents :: IO [Int]
 putStrLn (bool "impossible" "possible" (anyClosed w h ms))

anyClosed w h ms = any (isClosed w ims) (group (sort ms))
 where ims = zip [i | i<-[1..(w+1)*h], mod i (w+1) /= 0] ms

isClosed w ims (n:ns) = sum (degree w is) >= length (n:ns) * 2
 where is = map fst (filter ((==n).snd) ims)

degree w is = map (\i -> length (intersect [i-1,i+1,i-(w+1),i+(w+1)] is)) is
0