March of the Penguins
Time limit5sMemory limit128 MB
Determine, for each candidate ice floe, whether a max-flow feasibility check (respecting per-floe departure jump capacities and distance-limited edges) allows all penguins from every floe to reach it.
Problem
Several penguins live on a glacier field in Antarctica. Each penguin stands on one of many ice floes drifting on the sea. A single floe may hold several penguins, and some floes may hold none at all.
Penguins are highly social, so they all want to gather on one floe. To do this they pick one floe as the destination and jump from floe to floe until every penguin has gathered there. Penguins cannot fly, however, so they cannot reach a floe that is too far away: a penguin may jump between two floes only if the Euclidean distance between them is at most .
Because of global warming the floes are melting, and some crack and sink after being used too many times. The penguins are experts on ice and know exactly how many jumps each floe can bear. When a penguin jumps from one floe to another, the floe it leaves (was standing on) is damaged once, while the floe it lands on is not. In other words, at most jumps may depart from floe .
Determine every floe on which all the penguins can gather.
Input
The first line contains the number of test cases ().
Each test case is given as follows.
- The first line contains the number of floes () and the maximum jump distance (). may be a real number.
- Each of the next lines contains , , , .
- , : the coordinates of the floe ()
- : the number of penguins standing on that floe ()
- : the maximum number of jumps that may depart from that floe ()
Floes are numbered from in the order they are given.
Output
For each test case, print on one line the numbers of all floes on which every penguin can gather, in ascending order and separated by spaces. If no floe allows all penguins to gather, print on that line instead.