結果
問題 |
No.55 正方形を描くだけの簡単なお仕事です。
|
ユーザー |
![]() |
提出日時 | 2017-06-23 14:27:38 |
言語 | Haskell (9.10.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 518 bytes |
コンパイル時間 | 8,332 ms |
コンパイル使用メモリ | 169,728 KB |
実行使用メモリ | 8,064 KB |
最終ジャッジ日時 | 2024-10-03 04:10:24 |
合計ジャッジ時間 | 3,386 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 WA * 6 |
コンパイルメッセージ
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:37: warning: [GHC-63394] [-Wx-partial] In the use of ‘tail’ (imported from Data.List, but defined in GHC.List): "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty." | 5 | eqEdge xs = and $ zipWith (==) xs' (tail xs') | ^^^^ [2 of 2] Linking a.out
ソースコード
import Control.Monad import Data.Maybe import Data.List eqEdge xs = and $ zipWith (==) xs' (tail xs') where xs' = take 4 (sort xs) dist ((x1,y1),(x2,y2)) = (x2-x1)^2 + (y2-y1)^2 main = do [x1,y1,x2,y2,x3,y3] <- map read . words <$> getLine :: IO [Int] putStrLn $ maybe "-1" (unwords . map show) $ listToMaybe (square (x1,y1) (x2,y2) (x3,y3)) square p1 p2 p3 = do x4 <- [-100..100] y4 <- [-100..100] let p4 = (x4,y4) guard $ eqEdge (map dist [(p1,p2),(p1,p3),(p1,p4),(p2,p3),(p2,p4),(p3,p4)]) return [x4,y4]