結果
問題 | No.1065 電柱 / Pole (Easy) |
ユーザー | Theta |
提出日時 | 2023-01-27 18:22:13 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,331 bytes |
コンパイル時間 | 170 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 139,004 KB |
最終ジャッジ日時 | 2024-06-28 03:40:13 |
合計ジャッジ時間 | 32,229 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
10,880 KB |
testcase_01 | AC | 31 ms
10,880 KB |
testcase_02 | AC | 1,463 ms
74,280 KB |
testcase_03 | TLE | - |
testcase_04 | TLE | - |
testcase_05 | TLE | - |
testcase_06 | TLE | - |
testcase_07 | AC | 494 ms
43,272 KB |
testcase_08 | AC | 1,774 ms
139,004 KB |
testcase_09 | AC | 178 ms
21,120 KB |
testcase_10 | AC | 814 ms
68,452 KB |
testcase_11 | AC | 562 ms
47,312 KB |
testcase_12 | AC | 918 ms
37,376 KB |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | AC | 1,493 ms
61,152 KB |
testcase_17 | TLE | - |
testcase_18 | AC | 1,153 ms
49,968 KB |
testcase_19 | TLE | - |
testcase_20 | AC | 665 ms
41,148 KB |
testcase_21 | AC | 1,539 ms
57,216 KB |
testcase_22 | TLE | - |
testcase_23 | AC | 57 ms
12,032 KB |
testcase_24 | AC | 63 ms
12,416 KB |
testcase_25 | AC | 796 ms
34,432 KB |
testcase_26 | AC | 1,366 ms
65,508 KB |
testcase_27 | AC | 1,547 ms
64,608 KB |
testcase_28 | TLE | - |
testcase_29 | AC | 385 ms
24,320 KB |
testcase_30 | TLE | - |
testcase_31 | AC | 1,641 ms
85,268 KB |
testcase_32 | AC | 1,065 ms
57,556 KB |
testcase_33 | TLE | - |
testcase_34 | AC | 1,094 ms
51,128 KB |
testcase_35 | TLE | - |
testcase_36 | AC | 44 ms
11,520 KB |
testcase_37 | AC | 53 ms
12,160 KB |
testcase_38 | AC | 46 ms
11,776 KB |
testcase_39 | AC | 52 ms
12,288 KB |
testcase_40 | AC | 40 ms
11,136 KB |
testcase_41 | TLE | - |
testcase_42 | AC | 796 ms
47,828 KB |
testcase_43 | AC | 1,409 ms
77,108 KB |
testcase_44 | AC | 501 ms
36,028 KB |
testcase_45 | AC | 1,350 ms
75,708 KB |
testcase_46 | AC | 31 ms
10,880 KB |
testcase_47 | AC | 31 ms
11,008 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()