結果

問題 No.424 立体迷路
ユーザー aimyaimy
提出日時 2017-04-24 15:13:44
言語 Haskell
(9.8.2)
結果
AC  
実行時間 622 ms / 2,000 ms
コード長 768 bytes
コンパイル時間 7,896 ms
コンパイル使用メモリ 201,228 KB
実行使用メモリ 10,452 KB
最終ジャッジ日時 2023-09-18 17:01:50
合計ジャッジ時間 9,576 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,476 KB
testcase_01 AC 3 ms
7,288 KB
testcase_02 AC 3 ms
7,292 KB
testcase_03 AC 3 ms
7,300 KB
testcase_04 AC 3 ms
7,416 KB
testcase_05 AC 3 ms
7,348 KB
testcase_06 AC 3 ms
7,284 KB
testcase_07 AC 3 ms
7,296 KB
testcase_08 AC 2 ms
7,264 KB
testcase_09 AC 3 ms
7,376 KB
testcase_10 AC 3 ms
7,352 KB
testcase_11 AC 2 ms
7,364 KB
testcase_12 AC 3 ms
7,364 KB
testcase_13 AC 3 ms
7,488 KB
testcase_14 AC 3 ms
7,440 KB
testcase_15 AC 3 ms
7,412 KB
testcase_16 AC 3 ms
7,512 KB
testcase_17 AC 412 ms
8,712 KB
testcase_18 AC 422 ms
8,708 KB
testcase_19 AC 423 ms
8,744 KB
testcase_20 AC 413 ms
8,860 KB
testcase_21 AC 3 ms
7,384 KB
testcase_22 AC 3 ms
7,424 KB
testcase_23 AC 3 ms
7,344 KB
testcase_24 AC 622 ms
10,276 KB
testcase_25 AC 613 ms
10,452 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.Graph
import Data.Char
import Data.Bool
import Control.Monad

idx w x y = x*w + y

main = do
 [h,w] <- map read . words <$> getLine
 [sx,sy,gx,gy] <- map read . words <$> getLine
 bs <- map digitToInt . filter isDigit <$> getContents
 putStrLn (bool "NO" "YES" (maze h w (sx-1) (sy-1) (gx-1) (gy-1) bs))

maze h w sx sy gx gy bs = path g (idx w sx sy) (idx w gx gy)
 where
  g = buildG (0,h*w-1) $ do
   x1 <- [0..h-1]
   y1 <- [0..w-1]
   x2 <- [0..h-1]
   y2 <- [0..w-1]
   let v1 = idx w x1 y1
   let v2 = idx w x2 y2
   let d = abs (v1-v2)
   guard (elem d [1,w] || (elem d [2,2*w] && bs!!v1==bs!!v2 && bs!!(div (v1+v2) 2) < bs!!v1))
   guard (if elem d [1,2] then div v1 w == div v2 w else True)
   guard (abs (bs!!v1 - bs!!v2) <= 1)
   return (v1,v2)
0