結果
問題 | No.1065 電柱 / Pole (Easy) |
ユーザー | mkawa2 |
提出日時 | 2021-11-07 11:16:18 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 964 ms / 2,000 ms |
コード長 | 1,314 bytes |
コンパイル時間 | 343 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 143,360 KB |
最終ジャッジ日時 | 2024-11-08 23:18:08 |
合計ジャッジ時間 | 23,367 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
52,992 KB |
testcase_01 | AC | 44 ms
52,992 KB |
testcase_02 | AC | 428 ms
108,544 KB |
testcase_03 | AC | 616 ms
143,360 KB |
testcase_04 | AC | 712 ms
143,232 KB |
testcase_05 | AC | 471 ms
139,392 KB |
testcase_06 | AC | 488 ms
139,264 KB |
testcase_07 | AC | 172 ms
93,824 KB |
testcase_08 | AC | 403 ms
140,940 KB |
testcase_09 | AC | 120 ms
81,408 KB |
testcase_10 | AC | 232 ms
105,344 KB |
testcase_11 | AC | 190 ms
96,640 KB |
testcase_12 | AC | 146 ms
88,448 KB |
testcase_13 | AC | 648 ms
120,192 KB |
testcase_14 | AC | 666 ms
127,232 KB |
testcase_15 | AC | 826 ms
138,880 KB |
testcase_16 | AC | 426 ms
104,576 KB |
testcase_17 | AC | 915 ms
142,208 KB |
testcase_18 | AC | 358 ms
97,152 KB |
testcase_19 | AC | 753 ms
138,752 KB |
testcase_20 | AC | 311 ms
93,440 KB |
testcase_21 | AC | 445 ms
101,760 KB |
testcase_22 | AC | 788 ms
132,736 KB |
testcase_23 | AC | 72 ms
70,784 KB |
testcase_24 | AC | 73 ms
71,552 KB |
testcase_25 | AC | 136 ms
85,888 KB |
testcase_26 | AC | 408 ms
107,904 KB |
testcase_27 | AC | 427 ms
109,184 KB |
testcase_28 | AC | 671 ms
130,560 KB |
testcase_29 | AC | 193 ms
83,584 KB |
testcase_30 | AC | 677 ms
134,656 KB |
testcase_31 | AC | 592 ms
119,936 KB |
testcase_32 | AC | 336 ms
102,656 KB |
testcase_33 | AC | 885 ms
139,136 KB |
testcase_34 | AC | 385 ms
98,304 KB |
testcase_35 | AC | 650 ms
136,832 KB |
testcase_36 | AC | 70 ms
67,968 KB |
testcase_37 | AC | 102 ms
77,440 KB |
testcase_38 | AC | 79 ms
71,040 KB |
testcase_39 | AC | 83 ms
73,216 KB |
testcase_40 | AC | 59 ms
62,720 KB |
testcase_41 | AC | 964 ms
141,908 KB |
testcase_42 | AC | 340 ms
98,432 KB |
testcase_43 | AC | 453 ms
111,104 KB |
testcase_44 | AC | 220 ms
89,856 KB |
testcase_45 | AC | 540 ms
111,360 KB |
testcase_46 | AC | 43 ms
53,120 KB |
testcase_47 | AC | 43 ms
53,120 KB |
ソースコード
import sys sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.buffer.readline()) def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def LI1(): return list(map(int1, sys.stdin.buffer.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def BI(): return sys.stdin.buffer.readline().rstrip() def SI(): return sys.stdin.buffer.readline().rstrip().decode() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] dij = [(0, 1), (1, 0), (1, 1), (1, -1)] inf = 10**16 # md = 998244353 md = 10**9+7 from heapq import * def Dist(u, v): x0, y0 = xy[u] x1, y1 = xy[v] return ((x1-x0)**2+(y1-y0)**2)**0.5 n, m = LI() su, gu = LI1() xy = LLI(n) to = [[] for _ in range(n)] for _ in range(m): u, v = LI1() d = Dist(u, v) to[u].append((v, d)) to[v].append((u, d)) dist = [inf]*n dist[su] = 0 hp = [(0, su)] while hp: d, u = heappop(hp) if u == gu: print(d) break if d > dist[u]: continue for v, c in to[u]: nd = d+c if nd >= dist[v]: continue dist[v] = nd heappush(hp, (nd, v))