結果
問題 | No.2354 Poor Sight in Winter |
ユーザー | 👑 AngrySadEight |
提出日時 | 2023-04-04 09:40:20 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 505 ms / 2,000 ms |
コード長 | 1,462 bytes |
コンパイル時間 | 365 ms |
コンパイル使用メモリ | 82,028 KB |
実行使用メモリ | 101,576 KB |
最終ジャッジ日時 | 2024-09-25 11:04:58 |
合計ジャッジ時間 | 6,540 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
54,368 KB |
testcase_01 | AC | 39 ms
54,228 KB |
testcase_02 | AC | 39 ms
53,572 KB |
testcase_03 | AC | 39 ms
53,196 KB |
testcase_04 | AC | 40 ms
53,776 KB |
testcase_05 | AC | 38 ms
54,236 KB |
testcase_06 | AC | 39 ms
54,372 KB |
testcase_07 | AC | 38 ms
53,380 KB |
testcase_08 | AC | 41 ms
53,884 KB |
testcase_09 | AC | 48 ms
63,624 KB |
testcase_10 | AC | 47 ms
61,952 KB |
testcase_11 | AC | 284 ms
98,788 KB |
testcase_12 | AC | 275 ms
98,744 KB |
testcase_13 | AC | 505 ms
101,576 KB |
testcase_14 | AC | 458 ms
101,352 KB |
testcase_15 | AC | 377 ms
99,516 KB |
testcase_16 | AC | 396 ms
99,900 KB |
testcase_17 | AC | 446 ms
100,084 KB |
testcase_18 | AC | 237 ms
84,700 KB |
testcase_19 | AC | 368 ms
92,204 KB |
testcase_20 | AC | 264 ms
85,412 KB |
testcase_21 | AC | 113 ms
76,728 KB |
testcase_22 | AC | 180 ms
81,360 KB |
testcase_23 | AC | 191 ms
81,900 KB |
testcase_24 | AC | 300 ms
89,996 KB |
testcase_25 | AC | 148 ms
79,356 KB |
testcase_26 | AC | 134 ms
78,456 KB |
testcase_27 | AC | 85 ms
77,048 KB |
testcase_28 | AC | 108 ms
76,648 KB |
ソースコード
import heapq def dijkstra(graph, v, dist, P): hq = [] heapq.heappush(hq, [0, v]) dist[v] = 0 while len(hq) > 0: min_d, cur = heapq.heappop(hq) if dist[cur] != min_d: continue for next_cur, next_d in graph[cur]: if dist[next_cur] > dist[cur] + (next_d + P - 1) // P - 1: dist[next_cur] = dist[cur] + (next_d + P - 1) // P - 1 heapq.heappush(hq, [dist[next_cur], next_cur]) N, K = map(int, input().split()) sx, sy, gx, gy = map(int, input().split()) graph = [[] for _ in range(N + 2)] X = [] Y = [] for i in range(N): x, y = map(int, input().split()) X.append(x) Y.append(y) for i in range(N): for j in range(N): if i != j: graph[i].append([j, abs(X[i] - X[j]) + abs(Y[i] - Y[j])]) for i in range(N): graph[N].append([i, abs(X[i] - sx) + abs(Y[i] - sy)]) graph[i].append([N, abs(X[i] - sx) + abs(Y[i] - sy)]) for i in range(N): graph[N + 1].append([i, abs(X[i] - gx) + abs(Y[i] - gy)]) graph[i].append([N + 1, abs(X[i] - gx) + abs(Y[i] - gy)]) graph[N].append([N + 1, abs(sx - gx) + abs(sy - gy)]) graph[N + 1].append([N, abs(sx - gx) + abs(sy - gy)]) INF = 10 ** 7 ng = 0 ok = 200002 while ok - ng > 1: center = (ok + ng) // 2 dist = [INF for _ in range(N + 2)] dijkstra(graph, N, dist, center) if dist[N + 1] <= K: ok = center else: ng = center #print(ok, ng) print(ok)