結果
問題 | No.168 ものさし |
ユーザー | gigurururu |
提出日時 | 2015-03-20 19:25:50 |
言語 | Haskell (9.8.2) |
結果 |
AC
|
実行時間 | 1,174 ms / 2,000 ms |
コード長 | 1,338 bytes |
コンパイル時間 | 1,402 ms |
コンパイル使用メモリ | 165,416 KB |
実行使用メモリ | 89,516 KB |
最終ジャッジ日時 | 2023-08-25 20:52:43 |
合計ジャッジ時間 | 6,794 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 193 ms
27,964 KB |
testcase_01 | AC | 3 ms
7,360 KB |
testcase_02 | AC | 3 ms
7,340 KB |
testcase_03 | AC | 2 ms
7,492 KB |
testcase_04 | AC | 3 ms
7,368 KB |
testcase_05 | AC | 2 ms
7,540 KB |
testcase_06 | AC | 3 ms
7,348 KB |
testcase_07 | AC | 2 ms
7,600 KB |
testcase_08 | AC | 2 ms
7,344 KB |
testcase_09 | AC | 6 ms
9,452 KB |
testcase_10 | AC | 22 ms
12,792 KB |
testcase_11 | AC | 162 ms
27,624 KB |
testcase_12 | AC | 343 ms
38,332 KB |
testcase_13 | AC | 1,115 ms
89,516 KB |
testcase_14 | AC | 22 ms
12,120 KB |
testcase_15 | AC | 2 ms
7,468 KB |
testcase_16 | AC | 5 ms
8,656 KB |
testcase_17 | AC | 12 ms
11,868 KB |
testcase_18 | AC | 12 ms
10,924 KB |
testcase_19 | AC | 453 ms
51,676 KB |
testcase_20 | AC | 243 ms
37,940 KB |
testcase_21 | AC | 1,174 ms
88,472 KB |
testcase_22 | AC | 422 ms
49,556 KB |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
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 pqIsEmpty pq = S.null pq hypot2:: Integer -> Integer -> Integer hypot2 x y = x*x+y*y solve :: Int -> [[Integer]] -> Integer solve n l = adjust where adjust = if ansd*ansd < ans then ansd+10 else ansd ansd = (*10) . ceiling . sqrt . (/100) . fromIntegral $ ans ans :: Integer ans = primlike pqEmpty (pqAdd pqEmpty (0,0)) 10 dst:: Int -> [(Integer,Int)] dst i = let [x1,y1] = (la!i) in map (\(j,[x2,y2])->(hypot2 (x1-x2) (y1-y2),j)) $ zip [0..] l la = listArray (0,n-1) l primlike:: S.Set (Int) -> S.Set ((Integer,Int)) -> Integer -> Integer primlike visited pq mx | d==n-1 = max my mx | pqMember visited d = primlike visited nextpq mx | otherwise = primlike (pqAdd visited d) (foldl pqAdd nextpq $ filter (not . pqMember visited . snd) (dst d)) $ max mx my where ((my,d),nextpq) = 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