結果
| 問題 |
No.105 arcの六角ボルト
|
| コンテスト | |
| ユーザー |
kou_kkk
|
| 提出日時 | 2025-08-06 20:59:20 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 505 ms / 5,000 ms |
| コード長 | 664 bytes |
| コンパイル時間 | 10,216 ms |
| コンパイル使用メモリ | 186,240 KB |
| 実行使用メモリ | 73,472 KB |
| 最終ジャッジ日時 | 2025-08-06 20:59:32 |
| 合計ジャッジ時間 | 12,174 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.10.1/environments/default
[1 of 2] Compiling Main ( Main.hs, Main.o )
Main.hs:14:23: warning: [GHC-63394] [-Wx-partial]
In the use of ‘head’
(imported from Prelude, but defined in GHC.Internal.List):
"This is a partial function, it throws an error on empty lists. Use pattern matching, 'Data.List.uncons' or 'Data.Maybe.listToMaybe' instead. Consider refactoring to use "Data.List.NonEmpty"."
|
14 | step a b = let x1 = head a
| ^^^^
Main.hs:15:23: warning: [GHC-63394] [-Wx-partial]
In the use of ‘head’
(imported from Prelude, but defined in GHC.Internal.List):
"This is a partial function, it throws an error on empty lists. Use pattern matching, 'Data.List.uncons' or 'Data.Maybe.listToMaybe' instead. Consider refactoring to use "Data.List.NonEmpty"."
|
15 | x2 = head b
| ^^^^
Main.hs:28:42: warning: [GHC-63394] [-Wx-partial]
In the use of ‘tail’
(imported from Prelude, but defined in GHC.Internal.List):
"This is a partial function, it throws an error on empty lists. Replace it with 'drop' 1, or use pattern matching or 'GHC.Internal.Data.List.uncons' instead. Consider refactoring to use "Data.List.NonEmpty"."
|
28 | getDoubleList = map (map read . words) . tail <$> replicateM 7 getLine
| ^^^^
[2 of 2] Linking a.out
ソースコード
module Main where
import Control.Monad (replicateM)
main :: IO ()
main = do
t <- readLn
xss <- replicateM t getDoubleList
mapM_ (print . solve) xss
solve :: [[Double]] -> Double
solve = calc . foldr step [0.0, 0.0] . filter isPosiAll
where
step a b = let x1 = head a
x2 = head b
in if x1 > x2 then a else b
calc :: [Double] -> Double
calc xy | y <= 0.0 = 0.0
| otherwise = atan(y / x) * 180 / pi
where
(x : y : _) = xy
isPosiAll :: [Double] -> Bool
isPosiAll = all (>= -0.00000000001)
getDoubleList :: IO [[Double]]
getDoubleList = map (map read . words) . tail <$> replicateM 7 getLine
kou_kkk