結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー |
|
提出日時 | 2016-07-07 06:09:47 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 718 bytes |
コンパイル時間 | 10,391 ms |
コンパイル使用メモリ | 173,696 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-14 13:55:09 |
合計ジャッジ時間 | 6,626 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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:6:1: warning: [GHC-94817] [-Wtabs] Tab character found here, and in 12 further locations. Suggested fix: Please use spaces instead. | 6 | | (x1 - x2) ^ 2 + (y1 - y2) ^ 2 == (x3 - x2) ^ 2 + (y3 - y2) ^ 2 && (x1 - x2) * (x3 - x2) + (y1 - y2) * (y3 - y2) == 0 = Just (x1 + x3 - x2, y1 + y3 - y2) | ^^^^^^^^ [2 of 2] Linking a.out
ソースコード
import Data.List import Control.Applicative check :: Integral a => (a, a) -> (a, a) -> (a, a) -> Maybe (a, a) check (x1, y1) (x2, y2) (x3, y3) | (x1 - x2) ^ 2 + (y1 - y2) ^ 2 == (x3 - x2) ^ 2 + (y3 - y2) ^ 2 && (x1 - x2) * (x3 - x2) + (y1 - y2) * (y3 - y2) == 0 = Just (x1 + x3 - x2, y1 + y3 - y2) | otherwise = Nothing func :: Maybe a -> Maybe a -> Maybe a Nothing `func` Nothing = Nothing Nothing `func` x = x x `func` y = x main = do [x1, y1, x2, y2, x3, y3] <- return . map (read::String->Int) . words =<< getLine let p = foldl1 func $ fmap (\(p1:p2:p3:_) -> check p1 p2 p3) $ permutations [(x1, y1), (x2, y2), (x3, y3)] putStrLn $ case p of Just (x, y) -> unwords [show x, show y] Nothing -> "-1"