Submission #42043871
Source Code Expand
Copy
# dijkstraimport heapq########################################class bellmanFord():INF = float("inf")def __init__(self, v):self.numv = vself.distance = [self.INF] * vself.e = [[] for _ in range(v)]def makeEdge(self, s, t, cost):self.e[s].append((t, cost))self.e[t].append((s, cost))def solve(self, s):self.distance[s] = 0negativeCycle = Falsefor i in range(self.numv):for curNode in range(self.numv):for nextNode, cost in self.e[curNode]:if self.distance[curNode] == self.INF:continueif self.distance[nextNode] > self.distance[curNode] + cost:
# dijkstra import heapq ######################################## class bellmanFord(): INF = float("inf") def __init__(self, v): self.numv = v self.distance = [self.INF] * v self.e = [[] for _ in range(v)] def makeEdge(self, s, t, cost): self.e[s].append((t, cost)) self.e[t].append((s, cost)) def solve(self, s): self.distance[s] = 0 negativeCycle = False for i in range(self.numv): for curNode in range(self.numv): for nextNode, cost in self.e[curNode]: if self.distance[curNode] == self.INF: continue if self.distance[nextNode] > self.distance[curNode] + cost: isUpdate = True self.distance[nextNode] = self.distance[curNode] + cost if i == self.numv - 1: negativeCycle = True break if negativeCycle: return -1 return self.distance ######################################## n, d = map(int, input().split()) dat = [] for _ in range(n): dat.append(tuple(map(int, input().split()))) dj = bellmanFord(n) for i in range(n): x1, y1 = dat[i] for j in range(i+1, n): x2, y2 = dat[j] if (x1-x2)**2 + (y1-y2)**2 <= (d**2): dj.makeEdge(i, j, 1) cost = dj.solve(0) for i in range(n): print("Yes" if cost[i] != dj.INF else "No")
Submission Info
Submission Time | |
---|---|
Task | C - Virus |
User | recuraki |
Language | PyPy3 (7.3.0) |
Score | 0 |
Code Size | 1521 Byte |
Status | TLE |
Exec Time | 2213 ms |
Memory | 261704 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample00.txt, sample01.txt, sample02.txt |
All | sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt, testcase30.txt, testcase31.txt, testcase32.txt, testcase33.txt, testcase34.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample00.txt | AC | 66 ms | 62684 KB |
sample01.txt | AC | 50 ms | 62676 KB |
sample02.txt | AC | 54 ms | 62664 KB |
testcase00.txt | AC | 50 ms | 62612 KB |
testcase01.txt | AC | 246 ms | 75300 KB |
testcase02.txt | AC | 289 ms | 75940 KB |
testcase03.txt | AC | 251 ms | 75652 KB |
testcase04.txt | AC | 295 ms | 75300 KB |
testcase05.txt | AC | 876 ms | 76532 KB |
testcase06.txt | AC | 1178 ms | 76744 KB |
testcase07.txt | AC | 1251 ms | 76476 KB |
testcase08.txt | AC | 1589 ms | 77352 KB |
testcase09.txt | AC | 1358 ms | 76668 KB |
testcase10.txt | AC | 1729 ms | 77500 KB |
testcase11.txt | AC | 1047 ms | 76104 KB |
testcase12.txt | AC | 1134 ms | 76548 KB |
testcase13.txt | AC | 1268 ms | 77240 KB |
testcase14.txt | AC | 1738 ms | 77692 KB |
testcase15.txt | AC | 1341 ms | 77444 KB |
testcase16.txt | AC | 649 ms | 77148 KB |
testcase17.txt | AC | 1162 ms | 76644 KB |
testcase18.txt | AC | 778 ms | 77380 KB |
testcase19.txt | TLE | 2208 ms | 76192 KB |
testcase20.txt | AC | 712 ms | 77484 KB |
testcase21.txt | AC | 1138 ms | 77320 KB |
testcase22.txt | AC | 916 ms | 78176 KB |
testcase23.txt | AC | 1288 ms | 76876 KB |
testcase24.txt | AC | 900 ms | 78168 KB |
testcase25.txt | AC | 119 ms | 74932 KB |
testcase26.txt | AC | 130 ms | 74984 KB |
testcase27.txt | AC | 256 ms | 75616 KB |
testcase28.txt | AC | 271 ms | 75412 KB |
testcase29.txt | AC | 245 ms | 75356 KB |
testcase30.txt | AC | 254 ms | 75452 KB |
testcase31.txt | AC | 828 ms | 76296 KB |
testcase32.txt | TLE | 2208 ms | 78376 KB |
testcase33.txt | TLE | 2210 ms | 162924 KB |
testcase34.txt | TLE | 2213 ms | 261704 KB |