Back to problems

Detonate Bombs with Chain Reactions (Graph reachability)

Algorithm · Google · Medium

You have n bombs. Each entry bombs[i] = [xi, yi, ri] gives the position (xi, yi) of bomb i and its blast radius ri. Detonating bomb i causes every bomb j at Euclidean distance <= ri from it to explode. Any bomb exploded this way can set off additional bombs, creating a chain reaction. Select exactly one bomb to explode first. Determine the largest possible total number of detonated bombs. Input Line 1 contains the integer n. The following n lines each contain xi yi ri.…

Checking your access…