結果
問題 | No.2354 Poor Sight in Winter |
ユーザー | Shirotsume |
提出日時 | 2023-04-11 16:24:17 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 929 ms / 2,000 ms |
コード長 | 1,680 bytes |
コンパイル時間 | 212 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 282,740 KB |
最終ジャッジ日時 | 2024-10-07 09:51:59 |
合計ジャッジ時間 | 11,020 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
54,400 KB |
testcase_01 | AC | 44 ms
54,656 KB |
testcase_02 | AC | 43 ms
54,656 KB |
testcase_03 | AC | 44 ms
54,784 KB |
testcase_04 | AC | 43 ms
54,664 KB |
testcase_05 | AC | 42 ms
54,784 KB |
testcase_06 | AC | 44 ms
54,784 KB |
testcase_07 | AC | 45 ms
54,656 KB |
testcase_08 | AC | 45 ms
55,168 KB |
testcase_09 | AC | 62 ms
66,176 KB |
testcase_10 | AC | 61 ms
66,304 KB |
testcase_11 | AC | 746 ms
282,740 KB |
testcase_12 | AC | 787 ms
282,064 KB |
testcase_13 | AC | 929 ms
279,936 KB |
testcase_14 | AC | 912 ms
276,352 KB |
testcase_15 | AC | 892 ms
276,980 KB |
testcase_16 | AC | 905 ms
279,936 KB |
testcase_17 | AC | 895 ms
279,680 KB |
testcase_18 | AC | 344 ms
109,696 KB |
testcase_19 | AC | 570 ms
190,848 KB |
testcase_20 | AC | 381 ms
120,796 KB |
testcase_21 | AC | 164 ms
77,896 KB |
testcase_22 | AC | 265 ms
89,968 KB |
testcase_23 | AC | 255 ms
89,984 KB |
testcase_24 | AC | 503 ms
170,788 KB |
testcase_25 | AC | 212 ms
82,460 KB |
testcase_26 | AC | 210 ms
80,828 KB |
testcase_27 | AC | 113 ms
76,812 KB |
testcase_28 | AC | 146 ms
77,824 KB |
ソースコード
import sys from collections import deque, Counter input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 def Dijkstra(s, graph): INF = 2 ** 63 - 1 import heapq n = len(graph) dist = [INF] * n dist[s] = 0 bef = [0] * n bef[s] = s hq = [(0, s)] heapq.heapify(hq) while hq: c, now = heapq.heappop(hq) if c > dist[now]: continue for to, cost in graph[now]: if dist[now] + cost < dist[to]: dist[to] = cost + dist[now] bef[to] = now heapq.heappush(hq, (dist[to], + to)) return dist, bef def DijkstraRest(bef, t): now = t ret = [] while bef[now] != now: ret.append((bef[now], now)) now = bef[now] ret.reverse() return ret n, k = mi() assert 1 <= n <= 500 assert 0 <= k <= 10 ** 5 sx, sy, gx, gy = mi() XY = [(sx, sy), (gx, gy)] + [tuple(li()) for _ in range(n)] for x, y in XY: assert 0 <= x <= 10 ** 5 and 0 <= y <= 10 ** 5 assert len(set(XY)) == n + 2 def check(x): graph = [[] for _ in range(n + 2)] for i in range(n + 2): x1, y1 = XY[i] for j in range(i + 1, n + 2): x2, y2 = XY[j] dist = abs(x2 - x1) + abs(y2 - y1) cost = (dist - 1) // x graph[i].append((j, cost)) graph[j].append((i, cost)) d, _ = Dijkstra(0, graph) return d[1] <= k ok = 10 ** 9 ng = 0 while abs(ok - ng) > 1: mid = (ok + ng) // 2 if check(mid): ok = mid else: ng = mid print(ok)