結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー aimyaimy
提出日時 2017-06-23 14:50:41
言語 Haskell
(9.8.2)
結果
AC  
実行時間 78 ms / 5,000 ms
コード長 605 bytes
コンパイル時間 14,073 ms
コンパイル使用メモリ 175,616 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2024-04-14 06:56:52
合計ジャッジ時間 4,488 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
8,192 KB
testcase_01 AC 67 ms
8,064 KB
testcase_02 AC 42 ms
8,192 KB
testcase_03 AC 45 ms
8,064 KB
testcase_04 AC 71 ms
8,064 KB
testcase_05 AC 73 ms
8,064 KB
testcase_06 AC 73 ms
8,192 KB
testcase_07 AC 71 ms
8,064 KB
testcase_08 AC 71 ms
8,064 KB
testcase_09 AC 72 ms
8,064 KB
testcase_10 AC 72 ms
8,064 KB
testcase_11 AC 28 ms
8,064 KB
testcase_12 AC 78 ms
8,192 KB
testcase_13 AC 57 ms
8,192 KB
testcase_14 AC 36 ms
8,320 KB
testcase_15 AC 67 ms
8,064 KB
testcase_16 AC 37 ms
8,064 KB
testcase_17 AC 74 ms
8,064 KB
testcase_18 AC 22 ms
8,064 KB
testcase_19 AC 72 ms
8,064 KB
testcase_20 AC 42 ms
8,064 KB
testcase_21 AC 40 ms
8,064 KB
testcase_22 AC 69 ms
8,064 KB
testcase_23 AC 51 ms
8,192 KB
testcase_24 AC 22 ms
8,064 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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:7:38: 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."
  |
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.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."
  |
7 | eqEdge xs = (and $ zipWith equal es (tail es)) && (and $ zipWith equal ds (tail ds))
  |                                                                            ^^^^
[2 of 2] Linking a.out

ソースコード

diff #

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]
0