結果

問題 No.232 めぐるはめぐる (2)
ユーザー mazeppa1108
提出日時 2015-06-27 00:51:45
言語 Haskell
(9.10.1)
結果
RE  
実行時間 -
コード長 1,212 bytes
コンパイル時間 6,064 ms
コンパイル使用メモリ 171,520 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2024-07-07 19:45:37
合計ジャッジ時間 9,006 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 11 RE * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Data.List
import Control.Applicative
import Control.Monad

main = do
  [t, a, b] <- map read . words <$> getLine
  if a > t || b > t
     then putStrLn "NO"
     else do
       putStrLn "YES"
       mapM_ putStrLn $ move t 0 0 a b

move 1 x y a b = [arrowL (a - x) (b - y)]
move t x y a b = case arrow (a - x) (b - y) of
  "^" -> arrow (a - x) (b - y) : move (t - 1) x (y + 1) a b
  "^>" -> arrow (a - x) (b - y) : move (t - 1) (x + 1) (y + 1) a b
  ">" -> arrow (a - x) (b - y) : move (t - 1) (x + 1) y a b
  ">v" -> arrow (a - x) (b - y) : move (t - 1) (x + 1) (y - 1) a b
  "v" -> arrow (a - x) (b - y) : move (t - 1) x (y - 1) a b
  "<v" -> arrow (a - x) (b - y) : move (t - 1) (x - 1) (y - 1) a b
  "<" -> arrow (a - x) (b - y) : move (t - 1) (x - 1) y a b
  "<^" -> arrow (a - x) (b - y) : move (t - 1) (x - 1) (y + 1) a b

arrow 1 1 = "^"
arrow 1 0 = "v"
arrow 1 (-1) = ">"
arrow 0 (-1) = "<"
arrow (-1) (-1) = "v" 
arrow (-1) 0 = "^"
arrow (-1) 1 = "<"
arrow 0 1 = ">"
arrow x y 
  | x > 1 && y > 1 = "^>"
  | x > 1 = ">"
  | y > 1 = "^"

arrowL 1 1 = "^>"
arrowL 1 0 = ">"
arrowL 1 (-1) = ">v"
arrowL 0 (-1) = "v"
arrowL (-1) (-1) = "<v" 
arrowL (-1) 0 = "<"
arrowL (-1) 1 = "<^"
arrowL 0 1 = "^"
0