Submission #4624149
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]) ** 2 + (xyr[i][1] - xyr[j][1]) ** 2) ** 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 | 1476 Byte |
Status | TLE |
Exec Time | 2113 ms |
Memory | 127748 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 | AC | 21 ms | 3316 KB |
0_01.txt | AC | 21 ms | 3316 KB |
0_02.txt | AC | 21 ms | 3316 KB |
1_00.txt | AC | 21 ms | 3316 KB |
1_01.txt | AC | 21 ms | 3316 KB |
1_02.txt | AC | 1804 ms | 101452 KB |
1_03.txt | AC | 1915 ms | 105616 KB |
1_04.txt | AC | 1780 ms | 101188 KB |
1_05.txt | AC | 1940 ms | 104364 KB |
1_06.txt | AC | 1745 ms | 98152 KB |
1_07.txt | AC | 1809 ms | 100324 KB |
1_08.txt | AC | 1829 ms | 103732 KB |
1_09.txt | AC | 1816 ms | 104180 KB |
1_10.txt | AC | 1844 ms | 103896 KB |
1_11.txt | AC | 1817 ms | 101556 KB |
1_12.txt | AC | 1804 ms | 101404 KB |
1_13.txt | AC | 1826 ms | 100028 KB |
1_14.txt | AC | 1891 ms | 105752 KB |
1_15.txt | AC | 1873 ms | 105956 KB |
1_16.txt | AC | 1837 ms | 104908 KB |
1_17.txt | AC | 1834 ms | 104444 KB |
1_18.txt | AC | 1807 ms | 102300 KB |
1_19.txt | AC | 1859 ms | 105884 KB |
1_20.txt | AC | 1799 ms | 101500 KB |
1_21.txt | AC | 1768 ms | 100072 KB |
1_22.txt | AC | 1873 ms | 104448 KB |
1_23.txt | AC | 1834 ms | 104356 KB |
1_24.txt | AC | 1860 ms | 105484 KB |
1_25.txt | AC | 1841 ms | 103144 KB |
1_26.txt | AC | 1826 ms | 104588 KB |
1_27.txt | AC | 1853 ms | 100936 KB |
1_28.txt | AC | 1908 ms | 105148 KB |
1_29.txt | AC | 1877 ms | 105424 KB |
1_30.txt | AC | 1797 ms | 101356 KB |
1_31.txt | AC | 1907 ms | 102532 KB |
1_32.txt | AC | 1876 ms | 105156 KB |
1_33.txt | AC | 1818 ms | 101500 KB |
1_34.txt | AC | 1727 ms | 99144 KB |
1_35.txt | AC | 1834 ms | 103744 KB |
1_36.txt | AC | 1808 ms | 103168 KB |
1_37.txt | AC | 1767 ms | 101824 KB |
1_38.txt | TLE | 2113 ms | 127748 KB |
1_39.txt | TLE | 2112 ms | 127644 KB |
1_40.txt | TLE | 2111 ms | 125288 KB |
1_41.txt | TLE | 2112 ms | 127708 KB |
1_42.txt | AC | 1777 ms | 100928 KB |
1_43.txt | AC | 1850 ms | 106868 KB |
1_44.txt | AC | 1815 ms | 105176 KB |
1_45.txt | AC | 1829 ms | 107500 KB |