結果

問題 No.232 めぐるはめぐる (2)
ユーザー ducktailducktail
提出日時 2018-09-16 17:08:28
言語 Haskell
(9.6.2)
結果
WA  
実行時間 -
コード長 1,064 bytes
コンパイル時間 5,170 ms
コンパイル使用メモリ 162,648 KB
実行使用メモリ 11,052 KB
最終ジャッジ日時 2023-09-25 09:01:56
合計ジャッジ時間 8,551 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,960 KB
testcase_01 AC 32 ms
11,016 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
6,912 KB
testcase_05 AC 3 ms
6,912 KB
testcase_06 AC 2 ms
6,868 KB
testcase_07 AC 2 ms
6,952 KB
testcase_08 WA -
testcase_09 AC 3 ms
6,928 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 3 ms
6,920 KB
testcase_13 AC 2 ms
6,872 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 3 ms
6,908 KB
testcase_17 AC 3 ms
6,840 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
6,904 KB
testcase_22 AC 2 ms
6,924 KB
testcase_23 AC 3 ms
6,892 KB
testcase_24 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 Control.Applicative

main :: IO ()
main = solve <$> f >>= mapM_ putStrLn
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> [String]
solve [t, a, b]
  | mp < 0 = ["NO"]
  | a == 0 && b == 0 && t == 1 = ["NO"]
  | a == 0 && b == 0 && even mp = ["YES"] ++ (take mp $ cycle [">", "<"])
  | a == 0 && b == 0 = ["YES", ">", "^", "v<"] ++ (take (mp - 3) $ cycle [">", "<"])
  | a == 0 && even mp = ["YES"] ++ (take mp $ cycle [">", "<"]) ++ replicate b "^"
  | a == 0 = ["YES", "^>", "<"] ++ (take (mp - 1) $ cycle [">", "<"]) ++ replicate (b - 1) "^"
  | b == 0 && even mp = ["YES"] ++ (take mp $ cycle [">", "<"]) ++ replicate a ">"
  | b == 0 = ["YES", "^>", "v"] ++ (take (mp - 1) $ cycle [">", "<"]) ++ replicate (a - 1) ">"
  | otherwise = ["YES"] ++
                take (mp `div` 2 * 2) (cycle [">", "<"]) ++
                (if even mp then ["^>"] else [">","^"]) ++
                replicate (min a b - 1) "^>" ++
                (if a > b then replicate (a - b) ">" else replicate (b - a) "^")
  where
    mp = t - min a b - abs (a - b)
0