結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー |
![]() |
提出日時 | 2017-06-23 14:50:41 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 77 ms / 5,000 ms |
コード長 | 605 bytes |
コンパイル時間 | 2,108 ms |
コンパイル使用メモリ | 174,848 KB |
実行使用メモリ | 8,320 KB |
最終ジャッジ日時 | 2024-10-03 04:10:31 |
合計ジャッジ時間 | 4,331 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
コンパイルメッセージ
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
ソースコード
importControl.MonadimportData.MaybeimportData.Listequal x y = abs (x-y) < 1e-6eqEdge 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)^2main = do[x1,y1,x2,y2,x3,y3] <- map read . words <$> getLineputStrLn $ maybe "-1" (unwords . map show) $ listToMaybe (square (x1,y1) (x2,y2) (x3,y3))square p1 p2 p3 = dox4 <- [-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]