結果
| 問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
| コンテスト | |
| ユーザー |
aimy
|
| 提出日時 | 2017-06-23 14:50:41 |
| 言語 | Haskell (9.14.1) |
| 結果 |
AC
|
| 実行時間 | 80 ms / 5,000 ms |
| コード長 | 605 bytes |
| 記録 | |
| コンパイル時間 | 1,434 ms |
| コンパイル使用メモリ | 194,048 KB |
| 実行使用メモリ | 10,240 KB |
| 最終ジャッジ日時 | 2026-04-19 06:06:29 |
| 合計ジャッジ時間 | 6,429 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/environments/default
[1 of 2] Compiling Main ( Main.hs, Main.o )
Main.hs:7:38: warning: [GHC-63394] [-Wx-partial]
In the use of ‘tail’
(imported from Data.List, 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"."
|
7 | eqEdge xs = (and $ zipWith equal es (tail es)) && (and $ zipWith equal ds (tail ds))
| ^^^^
Main.hs:7:76: warning: [GHC-63394] [-Wx-partial]
In the use of ‘tail’
(imported from Data.List, 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"."
|
7 | eqEdge xs = (and $ zipWith equal es (tail es)) && (and $ zipWith equal ds (tail ds))
| ^^^^
[2 of 2] Linking a.out
ソースコード
import Control.Monad import Data.Maybe import Data.List equal x y = abs (x-y) < 1e-6 eqEdge xs = (and $ zipWith equal es (tail es)) && (and $ zipWith equal ds (tail ds)) where (es,ds) = splitAt 4 (sort xs) dist ((x1,y1),(x2,y2)) = sqrt $ fromIntegral $ (x2-x1)^2 + (y2-y1)^2 main = do [x1,y1,x2,y2,x3,y3] <- map read . words <$> getLine putStrLn $ maybe "-1" (unwords . map show) $ listToMaybe (square (x1,y1) (x2,y2) (x3,y3)) square p1 p2 p3 = do x4 <- [-200..200] y4 <- [-200..200] let p4 = (x4,y4) guard $ eqEdge (map dist [(p1,p2),(p1,p3),(p1,p4),(p2,p3),(p2,p4),(p3,p4)]) return [x4, y4]
aimy