結果
問題 | No.13 囲みたい! |
ユーザー | aimy |
提出日時 | 2017-05-11 09:20:37 |
言語 | Haskell (9.8.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 592 bytes |
コンパイル時間 | 10,185 ms |
コンパイル使用メモリ | 165,068 KB |
実行使用メモリ | 15,368 KB |
最終ジャッジ日時 | 2023-10-13 10:58:21 |
合計ジャッジ時間 | 11,942 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
7,524 KB |
testcase_01 | AC | 3 ms
7,776 KB |
testcase_02 | AC | 3 ms
7,568 KB |
testcase_03 | AC | 33 ms
14,500 KB |
testcase_04 | AC | 22 ms
14,168 KB |
testcase_05 | AC | 82 ms
14,700 KB |
testcase_06 | WA | - |
testcase_07 | AC | 32 ms
14,380 KB |
testcase_08 | AC | 92 ms
14,428 KB |
testcase_09 | WA | - |
testcase_10 | AC | 22 ms
11,916 KB |
testcase_11 | AC | 72 ms
13,792 KB |
testcase_12 | AC | 12 ms
11,324 KB |
testcase_13 | AC | 32 ms
12,440 KB |
testcase_14 | AC | 32 ms
12,472 KB |
testcase_15 | AC | 3 ms
8,052 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 Data.Bool import Data.List import qualified Data.IntSet 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 -> S.size (S.intersection (S.fromList [i-1,i+1,i-(w+1),i+(w+1)]) is')) is where is' = S.fromDistinctAscList is