Submission #4624354
Source Code Expand
from collections import defaultdict from heapq import heappop, heappush class Graph(object): def __init__(self): self.graph = defaultdict(list) def add_edge(self, a, b, w): self.graph[a].append((b, w)) class Dijkstra(object): def __init__(self, graph, s): self.g = graph.graph self.dist = defaultdict(lambda: float('inf')) self.dist[s] = 0 self.Q = [] heappush(self.Q, (self.dist[s], s)) while self.Q: dist_u, u = heappop(self.Q) if self.dist[u] < dist_u: continue for v, w in self.g[u]: alt = dist_u + w if self.dist[v] > alt: self.dist[v] = alt heappush(self.Q, (alt, v)) def s_d(self, goal): return self.dist[goal] xs, ys, xg, yg = list(map(int, input().split())) xyr = [] xyr.append([xs, ys, 0]) N = int(input()) for i in range(N): xyr.append(list(map(int, input().split()))) xyr.append([xg, yg, 0]) g_a = Graph() for i in range(N + 1): for j in range(i + 1, N + 2): a, b = i, j R = ((xyr[i][0] - xyr[j][0]) * (xyr[i][0] - xyr[j][0]) + (xyr[i][1] - xyr[j][1]) * (xyr[i][1] - xyr[j][1]) ** 0.5 if R > xyr[i][2] + xyr[j][2]: r = R - xyr[i][2] - xyr[j][2] else: r = 0 g_a.add_edge(a, b, r) g_a.add_edge(b, a, r) d_a = Dijkstra(g_a, 0) print(d_a.s_d(N + 1))
Submission Info
Submission Time | |
---|---|
Task | E - Cosmic Rays |
User | su_565fx |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 1519 Byte |
Status | RE |
Exec Time | 18 ms |
Memory | 3064 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 600 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | RE | 17 ms | 3064 KB |
0_01.txt | RE | 17 ms | 3064 KB |
0_02.txt | RE | 17 ms | 3064 KB |
1_00.txt | RE | 17 ms | 3064 KB |
1_01.txt | RE | 17 ms | 3064 KB |
1_02.txt | RE | 17 ms | 3064 KB |
1_03.txt | RE | 18 ms | 3064 KB |
1_04.txt | RE | 17 ms | 3064 KB |
1_05.txt | RE | 17 ms | 3064 KB |
1_06.txt | RE | 17 ms | 3064 KB |
1_07.txt | RE | 17 ms | 3064 KB |
1_08.txt | RE | 17 ms | 3064 KB |
1_09.txt | RE | 17 ms | 3064 KB |
1_10.txt | RE | 17 ms | 3064 KB |
1_11.txt | RE | 17 ms | 3064 KB |
1_12.txt | RE | 17 ms | 3064 KB |
1_13.txt | RE | 17 ms | 3064 KB |
1_14.txt | RE | 17 ms | 3064 KB |
1_15.txt | RE | 17 ms | 3064 KB |
1_16.txt | RE | 17 ms | 3064 KB |
1_17.txt | RE | 17 ms | 3064 KB |
1_18.txt | RE | 17 ms | 3064 KB |
1_19.txt | RE | 17 ms | 3064 KB |
1_20.txt | RE | 17 ms | 3064 KB |
1_21.txt | RE | 17 ms | 3064 KB |
1_22.txt | RE | 17 ms | 3064 KB |
1_23.txt | RE | 17 ms | 3064 KB |
1_24.txt | RE | 17 ms | 3064 KB |
1_25.txt | RE | 17 ms | 3064 KB |
1_26.txt | RE | 17 ms | 3064 KB |
1_27.txt | RE | 17 ms | 3064 KB |
1_28.txt | RE | 17 ms | 3064 KB |
1_29.txt | RE | 17 ms | 3064 KB |
1_30.txt | RE | 17 ms | 3064 KB |
1_31.txt | RE | 17 ms | 3064 KB |
1_32.txt | RE | 17 ms | 3064 KB |
1_33.txt | RE | 17 ms | 3064 KB |
1_34.txt | RE | 17 ms | 3064 KB |
1_35.txt | RE | 17 ms | 3064 KB |
1_36.txt | RE | 17 ms | 3064 KB |
1_37.txt | RE | 17 ms | 3064 KB |
1_38.txt | RE | 17 ms | 3064 KB |
1_39.txt | RE | 17 ms | 3064 KB |
1_40.txt | RE | 17 ms | 3064 KB |
1_41.txt | RE | 17 ms | 3064 KB |
1_42.txt | RE | 17 ms | 3064 KB |
1_43.txt | RE | 17 ms | 3064 KB |
1_44.txt | RE | 17 ms | 3064 KB |
1_45.txt | RE | 17 ms | 3064 KB |