結果
| 問題 |
No.232 めぐるはめぐる (2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-09-01 05:29:19 |
| 言語 | Haskell (9.10.1) |
| 結果 |
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 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 WA * 14 RE * 2 |
コンパイルメッセージ
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