結果
問題 | No.1065 電柱 / Pole (Easy) |
ユーザー | DrDrpilot |
提出日時 | 2022-09-05 17:51:52 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,118 ms / 2,000 ms |
コード長 | 1,308 bytes |
コンパイル時間 | 164 ms |
コンパイル使用メモリ | 82,148 KB |
実行使用メモリ | 142,952 KB |
最終ジャッジ日時 | 2024-04-30 20:53:54 |
合計ジャッジ時間 | 28,078 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 51 ms
62,520 KB |
testcase_01 | AC | 51 ms
61,432 KB |
testcase_02 | AC | 655 ms
110,792 KB |
testcase_03 | AC | 831 ms
142,952 KB |
testcase_04 | AC | 808 ms
141,600 KB |
testcase_05 | AC | 621 ms
140,696 KB |
testcase_06 | AC | 626 ms
140,832 KB |
testcase_07 | AC | 217 ms
94,180 KB |
testcase_08 | AC | 521 ms
141,300 KB |
testcase_09 | AC | 150 ms
83,744 KB |
testcase_10 | AC | 299 ms
106,316 KB |
testcase_11 | AC | 238 ms
96,916 KB |
testcase_12 | AC | 189 ms
88,292 KB |
testcase_13 | AC | 796 ms
119,744 KB |
testcase_14 | AC | 887 ms
125,768 KB |
testcase_15 | AC | 1,012 ms
135,212 KB |
testcase_16 | AC | 565 ms
105,088 KB |
testcase_17 | AC | 1,089 ms
140,540 KB |
testcase_18 | AC | 451 ms
97,508 KB |
testcase_19 | AC | 1,006 ms
136,404 KB |
testcase_20 | AC | 365 ms
93,476 KB |
testcase_21 | AC | 459 ms
101,800 KB |
testcase_22 | AC | 937 ms
130,712 KB |
testcase_23 | AC | 92 ms
77,812 KB |
testcase_24 | AC | 96 ms
78,052 KB |
testcase_25 | AC | 180 ms
88,336 KB |
testcase_26 | AC | 575 ms
108,900 KB |
testcase_27 | AC | 616 ms
109,136 KB |
testcase_28 | AC | 956 ms
130,048 KB |
testcase_29 | AC | 224 ms
84,328 KB |
testcase_30 | AC | 1,007 ms
134,516 KB |
testcase_31 | AC | 719 ms
118,052 KB |
testcase_32 | AC | 525 ms
104,196 KB |
testcase_33 | AC | 1,090 ms
136,108 KB |
testcase_34 | AC | 456 ms
98,252 KB |
testcase_35 | AC | 994 ms
135,896 KB |
testcase_36 | AC | 100 ms
78,180 KB |
testcase_37 | AC | 149 ms
79,028 KB |
testcase_38 | AC | 113 ms
78,108 KB |
testcase_39 | AC | 149 ms
79,052 KB |
testcase_40 | AC | 72 ms
69,992 KB |
testcase_41 | AC | 1,118 ms
142,168 KB |
testcase_42 | AC | 417 ms
97,696 KB |
testcase_43 | AC | 650 ms
112,460 KB |
testcase_44 | AC | 314 ms
90,372 KB |
testcase_45 | AC | 619 ms
111,168 KB |
testcase_46 | AC | 51 ms
61,556 KB |
testcase_47 | AC | 51 ms
61,524 KB |
ソースコード
def I():return int(input()) def MAP():return map(int,input().split()) def MAPs():return map(str,input().split()) def LI(): return list(map(int,input().split())) def TPL(): return tuple(map(int,input().split())) def S():return input() from collections import defaultdict,Counter,deque from copy import deepcopy from heapq import heapify,heappop,heappush from bisect import bisect_left,bisect_right from itertools import accumulate,product,permutations,combinations from math import gcd,ceil,floor,sqrt inf=float('inf') n,m=MAP() start,goal=MAP() point=[TPL() for _ in range(n)] g=[[] for _ in range(n)] for _ in range(m): p,q=MAP() x,y=point[p-1];X,Y=point[q-1] d=(x-X)**2+(y-Y)**2 d=sqrt(d) g[p-1].append((q-1,d)) g[q-1].append((p-1,d)) def dijkstra(start): dst=[10**18]*n visit=[False]*n q=[] heappush(q,(0,start)) while q: now_cost,now_place=heappop(q) if visit[now_place]: continue visit[now_place]=True dst[now_place]=now_cost for to_place,cost in g[now_place]: if visit[to_place]: continue if dst[to_place]>now_cost+cost: dst[to_place]=now_cost+cost heappush(q,(dst[to_place],to_place)) return dst print(dijkstra(start-1)[goal-1])