結果
問題 |
No.113 宝探し
|
ユーザー |
![]() |
提出日時 | 2019-08-22 08:22:41 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 551 bytes |
コンパイル時間 | 11,266 ms |
コンパイル使用メモリ | 180,972 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-16 22:09:15 |
合計ジャッジ時間 | 12,148 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
コンパイルメッセージ
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
ソースコード
import Control.Applicative ((<$>)) import Data.ByteString.Char8 (ByteString) import qualified Data.ByteString.Char8 as B import Text.Printf main :: IO () main = printf "%.5f" =<< solve <$> B.getLine solve :: ByteString -> Double solve bs = sqrt (s * s + t * t) where (x, y) = B.foldl' f (0, 0) bs (s, t) = (fromIntegral x, fromIntegral y) f :: (Int, Int) -> Char -> (Int, Int) f (x, y) c | c == 'N' = (x, y + 1) | c == 'E' = (x + 1, y) | c == 'W' = (x - 1, y) | c == 'S' = (x, y - 1) | otherwise = (x, y)