結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー 6soukiti296soukiti29
提出日時 2020-05-30 17:19:26
言語 Nim
(2.0.2)
結果
AC  
実行時間 431 ms / 2,000 ms
コード長 1,236 bytes
コンパイル時間 4,353 ms
コンパイル使用メモリ 72,624 KB
実行使用メモリ 39,980 KB
最終ジャッジ日時 2023-08-07 16:17:35
合計ジャッジ時間 14,536 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
13,336 KB
testcase_01 AC 16 ms
13,440 KB
testcase_02 AC 182 ms
25,396 KB
testcase_03 AC 282 ms
36,132 KB
testcase_04 AC 311 ms
36,352 KB
testcase_05 AC 263 ms
36,216 KB
testcase_06 AC 268 ms
37,300 KB
testcase_07 AC 95 ms
20,224 KB
testcase_08 AC 302 ms
31,328 KB
testcase_09 AC 48 ms
18,008 KB
testcase_10 AC 144 ms
21,748 KB
testcase_11 AC 105 ms
20,908 KB
testcase_12 AC 90 ms
23,264 KB
testcase_13 AC 218 ms
29,668 KB
testcase_14 AC 247 ms
33,920 KB
testcase_15 AC 297 ms
39,596 KB
testcase_16 AC 149 ms
24,072 KB
testcase_17 AC 335 ms
39,980 KB
testcase_18 AC 116 ms
22,424 KB
testcase_19 AC 292 ms
35,496 KB
testcase_20 AC 95 ms
20,940 KB
testcase_21 AC 141 ms
25,488 KB
testcase_22 AC 275 ms
35,960 KB
testcase_23 AC 19 ms
13,880 KB
testcase_24 AC 20 ms
13,904 KB
testcase_25 AC 82 ms
23,316 KB
testcase_26 AC 156 ms
25,116 KB
testcase_27 AC 162 ms
25,332 KB
testcase_28 AC 265 ms
34,448 KB
testcase_29 AC 58 ms
19,248 KB
testcase_30 AC 277 ms
38,784 KB
testcase_31 AC 215 ms
32,336 KB
testcase_32 AC 129 ms
24,932 KB
testcase_33 AC 301 ms
39,900 KB
testcase_34 AC 125 ms
21,416 KB
testcase_35 AC 275 ms
36,292 KB
testcase_36 AC 19 ms
13,536 KB
testcase_37 AC 20 ms
13,796 KB
testcase_38 AC 19 ms
13,632 KB
testcase_39 AC 20 ms
13,776 KB
testcase_40 AC 18 ms
13,468 KB
testcase_41 AC 431 ms
37,032 KB
testcase_42 AC 125 ms
20,988 KB
testcase_43 AC 200 ms
26,376 KB
testcase_44 AC 80 ms
20,636 KB
testcase_45 AC 219 ms
26,192 KB
testcase_46 AC 16 ms
13,316 KB
testcase_47 AC 17 ms
13,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils,strutils,math,heapqueue

type
    sen = tuple[b : int, d : float64 ]
    t = tuple[cost : float64, p : int]
var
    N, M : int
    X, Y : int
    p,q : int
    dentyuu = newSeq[array[2,int]](0)
    densen = newSeqWith(200010, newSeq[sen](0))
    hyou : array[200010, float64]
(N, M) = stdin.readline.split.map(parseInt)
(X, Y) = stdin.readline.split.map(parseInt)
X -= 1
Y -= 1

for n in 1..N:
    (p,q) = stdin.readline.split.map(parseInt)
    dentyuu.add([p, q])

for m in 1..M:
    (p, q) = stdin.readline.split.map(parseInt)
    p -= 1
    q -= 1
    var dx : float = (dentyuu[p][0] - dentyuu[q][0]).float
    var dy : float = (dentyuu[p][1] - dentyuu[q][1]).float
    dx = dx * dx
    dy = dy * dy
    var d = sqrt(dx + dy)
    var l : sen = (q, d)
    densen[p].add(l)
    l = (p, d)
    densen[q].add(l)

for i in 0..200000:
    hyou[i] = 1e10


var hp = initHeapQueue[t]()
var i : t = (0.0, X)
hp.push(i)

while true:
    var P = hp.pop()
    if hyou[P.p] < P.cost:
        continue
    if P.p == Y:
        break
    hyou[P.p] = P.cost
    for s in densen[P.p]:
        if hyou[s[0]] > s[1] + hyou[P.p]:
            hp.push((s[1] + hyou[P.p], s[0]))
            hyou[s[0]] = s[1] + hyou[P.p] 

echo hyou[Y]
    
0