結果

問題 No.232 めぐるはめぐる (2)
ユーザー mazeppa1108mazeppa1108
提出日時 2015-06-27 01:23:54
言語 Haskell
(9.8.2)
結果
AC  
実行時間 43 ms / 1,000 ms
コード長 1,260 bytes
コンパイル時間 7,827 ms
コンパイル使用メモリ 161,840 KB
実行使用メモリ 11,096 KB
最終ジャッジ日時 2023-10-12 13:34:59
合計ジャッジ時間 5,043 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
11,056 KB
testcase_01 AC 43 ms
10,944 KB
testcase_02 AC 42 ms
11,096 KB
testcase_03 AC 42 ms
11,020 KB
testcase_04 AC 3 ms
6,868 KB
testcase_05 AC 3 ms
6,844 KB
testcase_06 AC 3 ms
6,944 KB
testcase_07 AC 3 ms
6,752 KB
testcase_08 AC 32 ms
11,036 KB
testcase_09 AC 3 ms
6,840 KB
testcase_10 AC 2 ms
7,040 KB
testcase_11 AC 3 ms
6,984 KB
testcase_12 AC 2 ms
6,880 KB
testcase_13 AC 3 ms
6,968 KB
testcase_14 AC 3 ms
6,904 KB
testcase_15 AC 2 ms
6,948 KB
testcase_16 AC 2 ms
6,928 KB
testcase_17 AC 2 ms
6,928 KB
testcase_18 AC 3 ms
7,980 KB
testcase_19 AC 3 ms
6,944 KB
testcase_20 AC 2 ms
6,952 KB
testcase_21 AC 2 ms
6,820 KB
testcase_22 AC 3 ms
6,876 KB
testcase_23 AC 2 ms
6,932 KB
testcase_24 AC 3 ms
6,960 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.List
import Control.Applicative
import Control.Monad

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

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

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 0 0 = ">"
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