結果
問題 | No.1065 電柱 / Pole (Easy) |
ユーザー | はむ吉🐹 |
提出日時 | 2020-05-29 22:13:10 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,331 bytes |
コンパイル時間 | 359 ms |
コンパイル使用メモリ | 82,156 KB |
実行使用メモリ | 180,316 KB |
最終ジャッジ日時 | 2024-11-06 05:11:47 |
合計ジャッジ時間 | 39,863 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
53,876 KB |
testcase_01 | AC | 41 ms
53,716 KB |
testcase_02 | AC | 1,022 ms
127,780 KB |
testcase_03 | AC | 1,362 ms
177,528 KB |
testcase_04 | AC | 1,340 ms
175,860 KB |
testcase_05 | AC | 1,018 ms
175,928 KB |
testcase_06 | AC | 1,017 ms
176,300 KB |
testcase_07 | AC | 382 ms
103,004 KB |
testcase_08 | WA | - |
testcase_09 | AC | 233 ms
85,720 KB |
testcase_10 | AC | 544 ms
119,000 KB |
testcase_11 | AC | 410 ms
105,908 KB |
testcase_12 | AC | 302 ms
94,892 KB |
testcase_13 | AC | 1,220 ms
144,064 KB |
testcase_14 | AC | 1,323 ms
155,172 KB |
testcase_15 | AC | 1,608 ms
171,892 KB |
testcase_16 | AC | 891 ms
117,516 KB |
testcase_17 | AC | 1,688 ms
180,316 KB |
testcase_18 | AC | 651 ms
103,988 KB |
testcase_19 | AC | 1,568 ms
172,508 KB |
testcase_20 | AC | 522 ms
101,416 KB |
testcase_21 | AC | 748 ms
111,900 KB |
testcase_22 | AC | 1,448 ms
163,156 KB |
testcase_23 | AC | 92 ms
77,160 KB |
testcase_24 | AC | 98 ms
77,424 KB |
testcase_25 | AC | 274 ms
92,288 KB |
testcase_26 | AC | 890 ms
124,420 KB |
testcase_27 | AC | 912 ms
125,780 KB |
testcase_28 | AC | 1,532 ms
161,972 KB |
testcase_29 | AC | 315 ms
86,688 KB |
testcase_30 | AC | 1,531 ms
170,400 KB |
testcase_31 | AC | 1,086 ms
142,712 KB |
testcase_32 | AC | 761 ms
117,980 KB |
testcase_33 | AC | 1,665 ms
171,960 KB |
testcase_34 | AC | 656 ms
106,768 KB |
testcase_35 | AC | 1,578 ms
175,564 KB |
testcase_36 | AC | 112 ms
76,988 KB |
testcase_37 | AC | 173 ms
78,968 KB |
testcase_38 | AC | 130 ms
78,528 KB |
testcase_39 | AC | 175 ms
78,576 KB |
testcase_40 | AC | 74 ms
71,584 KB |
testcase_41 | AC | 1,890 ms
177,112 KB |
testcase_42 | AC | 656 ms
107,632 KB |
testcase_43 | AC | 1,011 ms
128,912 KB |
testcase_44 | AC | 461 ms
95,992 KB |
testcase_45 | AC | 980 ms
127,756 KB |
testcase_46 | AC | 42 ms
53,912 KB |
testcase_47 | AC | 42 ms
53,076 KB |
ソースコード
#!/usr/bin/env pypy3 import heapq import math INF = 10 ** 8 def dijkstra(num_vertices, adj_list, source=0): dist = [INF for _ in range(num_vertices)] dist[source] = 0 pq = [(dist[u], u) for u in range(num_vertices)] heapq.heapify(pq) while pq: _, u = heapq.heappop(pq) for v, cost in adj_list[u]: new_length = dist[u] + cost if new_length < dist[v]: dist[v] = new_length heapq.heappush(pq, (new_length, v)) return dist def minimize(n, adj_list, pole_start, pole_end): dist = dijkstra(n, adj_list, pole_start) res = dist[pole_end] return res def main(): n, m = (int(z) for z in input().split()) pole_start, pole_end = (int(z) - 1 for z in input().split()) pole_poss = [] for _ in range(n): x0, y0 = (float(z) for z in input().split()) pole_poss.append((x0, y0)) adj_list = [set() for _ in range(n)] for _ in range(m): st, en = (int(z) - 1 for z in input().split()) dist = math.hypot(pole_poss[st][0] - pole_poss[en][0], pole_poss[st][1] - pole_poss[en][1]) adj_list[st].add((en, dist)) adj_list[en].add((st, dist)) res = minimize(n, adj_list, pole_start, pole_end) print("{:.8f}".format(res)) if __name__ == '__main__': main()