結果
問題 | No.232 めぐるはめぐる (2) |
ユーザー | Haar |
提出日時 | 2016-09-01 05:29:19 |
言語 | Haskell (9.8.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,353 bytes |
コンパイル時間 | 9,386 ms |
コンパイル使用メモリ | 176,328 KB |
実行使用メモリ | 8,064 KB |
最終ジャッジ日時 | 2024-11-14 14:06:00 |
合計ジャッジ時間 | 11,837 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 27 ms
8,064 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 1 ms
6,820 KB |
testcase_05 | RE | - |
testcase_06 | WA | - |
testcase_07 | AC | 2 ms
6,816 KB |
testcase_08 | WA | - |
testcase_09 | AC | 2 ms
6,816 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | RE | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 1 ms
6,816 KB |
testcase_17 | AC | 1 ms
6,816 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 1 ms
6,816 KB |
testcase_22 | AC | 2 ms
6,816 KB |
testcase_23 | AC | 1 ms
6,816 KB |
testcase_24 | WA | - |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) Main.hs:5:1: warning: [GHC-94817] [-Wtabs] Tab character found here, and in 99 further locations. Suggested fix: Please use spaces instead. | 5 | [t,a,b] <- map (read::String->Int) . words <$> getLine | ^^^^^^^^ [2 of 2] Linking a.out
ソースコード
import Control.Applicative main :: IO() main = do [t,a,b] <- map (read::String->Int) . words <$> getLine if check t a b then do putStrLn "YES" mapM_ putStrLn $ route t a b else putStrLn "NO" check t a b | a > t || b > t = False | otherwise = True sign x | x > 0 = 1 | x < 0 = -1 | otherwise = 0 route t a b | a == b = if t''-t' == 0 then replicate min' (diag a b) else ([dir a 0, dir 0 b] ++ replicate (min'-1) (diag a b)) ++ (take t'' (cycle [diag a b, diag (-a) (-b)])) | a /= b = replicate min' (diag a b) ++ route' (t-min') (a-min'*(sign a)) (b-min'*(sign b)) where min' = minimum [abs a,abs b] diag x y | x > 0 && y > 0 = ">^" | x > 0 && y < 0 = ">v" | x < 0 && y > 0 = "<^" | x < 0 && y < 0 = "<v" | otherwise = "" dir x y | x > 0 = ">" | x < 0 = "<" | y > 0 = "^" | y < 0 = "v" t' = t - min' t'' = if t' `mod` 2 == 0 then t' else t' - 1 route' t a b = if t'-t'' == 0 then replicate cnt (dir a b) else ((cor a b) ++ replicate (cnt-1) (dir a b)) ++ (take t'' (cycle ["<",">"])) where dir x y | x > 0 = ">" | x < 0 = "<" | y > 0 = "^" | y < 0 = "v" | otherwise = "" cor x y | x > 0 = [">^","v"] | x < 0 = ["<v","^"] | y > 0 = [">^","<"] | y < 0 = ["<v",">"] | otherwise = [] cnt = a + b t' = t - cnt t'' = if t' `mod` 2 == 0 then t' else t' - 1