結果
問題 | No.1065 電柱 / Pole (Easy) |
ユーザー | McGregorsh |
提出日時 | 2023-07-12 21:15:19 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 963 ms / 2,000 ms |
コード長 | 1,966 bytes |
コンパイル時間 | 398 ms |
コンパイル使用メモリ | 82,028 KB |
実行使用メモリ | 167,668 KB |
最終ジャッジ日時 | 2024-09-14 10:09:33 |
合計ジャッジ時間 | 27,679 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 146 ms
88,436 KB |
testcase_01 | AC | 146 ms
88,436 KB |
testcase_02 | AC | 581 ms
128,472 KB |
testcase_03 | AC | 754 ms
167,616 KB |
testcase_04 | AC | 746 ms
167,180 KB |
testcase_05 | AC | 544 ms
167,480 KB |
testcase_06 | AC | 548 ms
167,668 KB |
testcase_07 | AC | 239 ms
105,592 KB |
testcase_08 | AC | 451 ms
165,324 KB |
testcase_09 | AC | 195 ms
95,664 KB |
testcase_10 | AC | 297 ms
121,616 KB |
testcase_11 | AC | 256 ms
111,924 KB |
testcase_12 | AC | 227 ms
105,124 KB |
testcase_13 | AC | 695 ms
142,684 KB |
testcase_14 | AC | 760 ms
149,692 KB |
testcase_15 | AC | 849 ms
160,380 KB |
testcase_16 | AC | 501 ms
124,988 KB |
testcase_17 | AC | 909 ms
166,480 KB |
testcase_18 | AC | 400 ms
115,048 KB |
testcase_19 | AC | 854 ms
160,820 KB |
testcase_20 | AC | 363 ms
108,932 KB |
testcase_21 | AC | 449 ms
121,292 KB |
testcase_22 | AC | 861 ms
153,792 KB |
testcase_23 | AC | 164 ms
89,940 KB |
testcase_24 | AC | 165 ms
89,596 KB |
testcase_25 | AC | 233 ms
105,108 KB |
testcase_26 | AC | 550 ms
128,008 KB |
testcase_27 | AC | 590 ms
128,576 KB |
testcase_28 | AC | 873 ms
155,584 KB |
testcase_29 | AC | 265 ms
98,596 KB |
testcase_30 | AC | 900 ms
159,520 KB |
testcase_31 | AC | 657 ms
139,116 KB |
testcase_32 | AC | 500 ms
121,740 KB |
testcase_33 | AC | 963 ms
160,196 KB |
testcase_34 | AC | 451 ms
115,796 KB |
testcase_35 | AC | 895 ms
161,656 KB |
testcase_36 | AC | 169 ms
89,700 KB |
testcase_37 | AC | 205 ms
90,776 KB |
testcase_38 | AC | 174 ms
89,532 KB |
testcase_39 | AC | 205 ms
91,144 KB |
testcase_40 | AC | 154 ms
88,820 KB |
testcase_41 | AC | 955 ms
165,820 KB |
testcase_42 | AC | 416 ms
113,736 KB |
testcase_43 | AC | 586 ms
130,452 KB |
testcase_44 | AC | 325 ms
104,508 KB |
testcase_45 | AC | 559 ms
128,684 KB |
testcase_46 | AC | 144 ms
88,804 KB |
testcase_47 | AC | 144 ms
88,628 KB |
ソースコード
###ダイクストラ### def daikusutora(N, G, s): dist = [INF] * N que = [(0, s)] dist[s] = 0 while que: c, v = heappop(que) if dist[v] < c: continue for t, cost in G[v]: if dist[v] + cost < dist[t]: dist[t] = dist[v] + cost heappush(que, (dist[t], t)) return dist import sys from sys import stdin from fractions import Fraction import math from math import ceil, floor, sqrt, pi, factorial, gcd from copy import deepcopy from collections import Counter, deque, defaultdict from heapq import heapify, heappop, heappush from itertools import accumulate, product, combinations, combinations_with_replacement, permutations from bisect import bisect, bisect_left, bisect_right from functools import reduce, lru_cache from decimal import Decimal, getcontext, ROUND_HALF_UP def i_input(): return int(stdin.readline()) def i_map(): return map(int, stdin.readline().split()) def i_list(): return list(i_map()) def s_input(): return stdin.readline()[:-1] def s_map(): return s_input().split() def s_list(): return list(s_map()) def lcm(a, b): return a * b // gcd(a, b) def get_distance(x1, y1, x2, y2): d = sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) return d def rotate(table): n_fild = [] for x in zip(*table[::-1]): n_fild.append(x) return n_fild sys.setrecursionlimit(10 ** 7) INF = float('inf') MOD = 10 ** 9 + 7 MOD2 = 998244353 alpa = 'abcdefghijklmnopqrstuvwxyz' ALPA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def main(): N, M = i_map() X, Y = i_map() X -= 1 Y -= 1 nums = [i_list() for i in range(N)] G = [[] for i in range(N)] for i in range(M): p, q = i_map() p -= 1 q -= 1 ax, ay = nums[p] bx, by = nums[q] cost = get_distance(ax, ay, bx, by) G[p].append([q, cost]) G[q].append([p, cost]) ans = daikusutora(N, G, X) print(ans[Y]) if __name__ == '__main__': main()