codingame - MEDIUM - Skynet: the Virus

This is a simple graph problem.

There are graph data, the position of 'Skynet agent' and Gateway node numbers.

Our goal is to prevent the approaching of Skynet Agent to the gateway.

This problem is so simple because we just can redraw links that connected with the gateway.

But there an additional achievement for consuming fewer links.

So I calculated the shortest path from the gateway to Skynet agent every each turn. And redraw the nearest link from Skynet agent.

source link