RadarSabotage
TCO11 Round 4 · 2011-05-07 · by vexorian
Problem Statement
The locations of the radars are given by
The Feudalian force must find a path to take between the bottom and top sides of the rectangle such that none of the points in the path are within the detection radius of any radar. Formally, the path must be a curve that connects two points (x0, 0) and (x1, H) which does not cross either of the two walls, and for every point (x,y) in the path and a radar i, the distance between (x,y) and the radar must be strictly larger than P*P where P is the power level of the radar.
You are a Feudalian spy with the ability to modify the power level of any radar to any non-negative integer value that is not larger than the radar's original power level. Set the power levels in such way that the Feudalian force can cross the rectangle without being detected. If there are multiple ways to do it, minimize the difference in total power consumption between the initial setup and the final setup so that the sabotage is more difficult to notice. Return the minimum difference in power usage that is required to make the land crossable.
Constraints
- W and H will each be between 3 and 1000, inclusive.
- radarX will contain between 1 and 30 elements, inclusive.
- radarX, radarY and radarPower will contain the same number of elements.
- Each element of radarX will be between 1 and W-1, inclusive.
- Each element of radarY will be between 1 and H-1, inclusive.
- Each element of radarPower will be between 1 and 200, inclusive.
- No two radars will be located at the same point.
8
20
{4}
{4}
{10}
Returns: 9
There is only one radar initially with a power level of 10. If the power level is changed to 1, the radius of the radar will become 1*1 = 1, and it will be possible to pass. If we only changed the level to 2, the radius would become 4, and it would not be possible to pass:
3
5
{1,1,2}
{1,2,2}
{1,1,1}
Returns: 1
If we turn the third radar off a path for the army will be possible.
6
16
{1,3,5}
{8,8,8}
{2,2,2}
Returns: 3
A possible solution is to set the first radar's power level to 0 and the second radar's level to 1.
51
4
{46,8}
{2,1}
{8,8}
Returns: 8
24
32
{3,6,10,18,13}
{18,23,10,13,26}
{2,2,2,3,1}
Returns: 0
The army is already able to cross without being detected. No change is necessary. Note that the path does not necessarily have to be a straight line:
Submissions are judged against all 111 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class RadarSabotage with a public method int minimumDifference(int W, int H, vector<int> radarX, vector<int> radarY, vector<int> radarPower) · 111 test cases · 2 s / 256 MB per case