結果
問題 | No.1065 電柱 / Pole (Easy) |
ユーザー |
|
提出日時 | 2023-01-27 18:22:13 |
言語 | Python3 (3.11.2 + numpy 1.24.2 + scipy 1.10.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,331 bytes |
コンパイル時間 | 244 ms |
コンパイル使用メモリ | 11,016 KB |
実行使用メモリ | 139,564 KB |
最終ジャッジ日時 | 2023-09-10 12:21:21 |
合計ジャッジ時間 | 61,553 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 18 ms
8,056 KB |
testcase_01 | AC | 17 ms
8,124 KB |
testcase_02 | AC | 1,209 ms
73,188 KB |
testcase_03 | TLE | - |
testcase_04 | TLE | - |
testcase_05 | AC | 1,653 ms
112,212 KB |
testcase_06 | AC | 1,649 ms
112,028 KB |
testcase_07 | AC | 400 ms
41,572 KB |
testcase_08 | AC | 1,447 ms
139,564 KB |
testcase_09 | AC | 141 ms
18,940 KB |
testcase_10 | AC | 665 ms
67,260 KB |
testcase_11 | AC | 449 ms
45,976 KB |
testcase_12 | AC | 819 ms
34,716 KB |
testcase_13 | AC | 1,990 ms
77,704 KB |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | AC | 1,473 ms
58,664 KB |
testcase_17 | TLE | - |
testcase_18 | AC | 1,094 ms
47,980 KB |
testcase_19 | TLE | - |
testcase_20 | AC | 591 ms
38,824 KB |
testcase_21 | AC | 1,502 ms
54,908 KB |
testcase_22 | TLE | - |
testcase_23 | AC | 40 ms
9,528 KB |
testcase_24 | AC | 46 ms
9,968 KB |
testcase_25 | AC | 721 ms
31,868 KB |
testcase_26 | AC | 1,285 ms
63,644 KB |
testcase_27 | AC | 1,489 ms
62,768 KB |
testcase_28 | TLE | - |
testcase_29 | AC | 345 ms
21,988 KB |
testcase_30 | TLE | - |
testcase_31 | AC | 1,571 ms
84,200 KB |
testcase_32 | AC | 1,023 ms
55,732 KB |
testcase_33 | TLE | - |
testcase_34 | AC | 1,021 ms
49,480 KB |
testcase_35 | TLE | - |
testcase_36 | AC | 29 ms
8,904 KB |
testcase_37 | AC | 35 ms
9,652 KB |
testcase_38 | AC | 30 ms
9,168 KB |
testcase_39 | AC | 35 ms
9,652 KB |
testcase_40 | AC | 23 ms
8,580 KB |
testcase_41 | TLE | - |
testcase_42 | AC | 703 ms
45,960 KB |
testcase_43 | AC | 1,177 ms
75,932 KB |
testcase_44 | AC | 421 ms
33,856 KB |
testcase_45 | AC | 1,134 ms
74,696 KB |
testcase_46 | AC | 18 ms
8,088 KB |
testcase_47 | AC | 17 ms
8,192 KB |
ソースコード
from heapq import heappop, heappush from math import inf, sqrt from operator import ne class Point: def __init__(self, x, y) -> None: self.x = x self.y = y def distance_to(self, __o: object): if not isinstance(__o, Point): raise ValueError return sqrt((self.x - __o.x)**2 + (self.y - __o.y)**2) def main(): N, M = map(int, input().split()) X, Y = map(int, input().split()) X -= 1 Y -= 1 nodes = [Point(*map(int, input().split())) for _ in range(N)] weights = [{} for _ in range(N)] for _ in range(M): start, end = map(int, input().split()) weights[start-1][end-1] = nodes[start-1].distance_to(nodes[end-1]) weights[end-1][start-1] = weights[start-1][end-1] unvisited = set(idx for idx in range(N)) searched = [] heappush(searched, (0, X)) costs = [inf for _ in range(N)] decided = set() while searched: current_cost, next_node_idx = heappop(searched) if next_node_idx in decided: continue costs[next_node_idx] = current_cost decided.add(next_node_idx) for dest_idx, distance in weights[next_node_idx].items(): heappush(searched, (current_cost + distance, dest_idx)) print(costs[Y]) if __name__ == "__main__": main()