結果
| 問題 | No.168 ものさし |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-03-20 19:08:48 |
| 言語 | Haskell (9.10.1) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,267 bytes |
| 記録 | |
| コンパイル時間 | 291 ms |
| コンパイル使用メモリ | 150,400 KB |
| 最終ジャッジ日時 | 2024-12-24 07:04:43 |
| 合計ジャッジ時間 | 647 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
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:1: error: [GHC-87110]
Could not load module ‘Data.Set’.
It is a member of the hidden package ‘containers-0.6.8’.
Use -v to see a list of the files searched for.
|
5 | import qualified Data.Set as S
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
import Control.Applicative
import Control.Monad
import Data.Array
import Data.Maybe
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B
pqEmpty = S.empty
pqAdd pq n = S.insert n pq
pqGet pq = S.deleteFindMin pq
pqMember pq n = S.member n pq
pqNotMember pq n = S.notMember n pq
pqIsEmpty pq = S.null pq
pqSingleton n = S.singleton n
hypot2:: Integer -> Integer -> Integer
hypot2 x y = x*x+y*y
solve :: Int -> [[Integer]] -> Integer
solve n l = if ansd^2 < ans then ansd+10 else ansd
where
ansd = (*10) . ceiling . sqrt . (/100) . fromIntegral $ ans
ans = primlike pqEmpty (pqSingleton (0,0)) 10
dst i = let [x1,y1] = la!i in map (\[x2,y2]->hypot2 (x1-x2) (y1-y2)) l
la = listArray (0,n-1) l
primlike visited pq mx
| d==n-1 = max mx my
| pqMember visited d = primlike visited gotpq mx
| otherwise = primlike (pqAdd visited d) addedpq $ max mx my
where
addedpq = foldl pqAdd gotpq $ filter (pqNotMember visited . snd) $ zip (dst d) [0..]
((my,d),gotpq) = pqGet pq
main = do
n <- fst . fromJust . B.readInt <$> B.getLine
l <- replicateM n $ map (fst . fromJust . B.readInteger) . B.words <$> B.getLine
print $ solve n l