시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 10 | 1 | 1 | 11.111% |
The parents of Hansel and Gretel would like to take their children out on a walk by night through the forest. Family hiking trips are a cherished family tradition, but Hansel and Gretel do not walk as fast as their parents. During previous walks, they therefore often lost track of them, causing them to be left on their own. At night the forest is a scary place, with predators lurking everywhere. Therefore, it is not hard to understand the children are not particularly looking forward to this walk.
Hansel and Gretel, who do not have GPS facilities, decide to prepare themselves for the walk by bringing lanterns to the forest by day. They can attach these lanterns to trees in the forest. At night, each lantern will then provide a circular spot of light (shadow effects are not taken into account). As predators do not like light, Hansel and Gretel will not be devoured as long as they will stay within the light provided by the lanterns. If they will attach lanterns to trees in the forest that are situated close enough to each other, the corresponding light spots will touch or overlap. This way, a light zone encompassing multiple trees is created, in which they can walk safely. First of all, Hansel and Gretel wonder how many trees can at most be illuminated in one connected light zone (the 'largest connected light zone' in terms of illuminated trees). If the largest connected light zone consists of multiple trees, there will only be one zone in the forest with this maximal number of trees.
Of course Hansel and Gretel can attach lanterns to all trees in this zone, but if trees are situated really close to each other, the light spot of one tree can actually already illuminate the other tree. Therefore, Hansel and Gretel might be able to bring less lanterns without reducing the number of trees they can see and reach in the lighted zone. As this reduces the weight to carry ánd the amounts of light pollution and emitted CO2, they now also are very interested in the smallest number of lanterns needed to illuminate all trees in the largest connected light zone, while maintaining the possibility to reach any tree in this zone from any other tree without having to step into the dark (see Figure 1 for an illustration). Poor Hansel and Gretel do not just lack GPS facilities, they also don't have a computer in their log cabin. You do, so maybe you can help them.
Figure 1: Two possible tree situations. On the left, at most three trees can be illuminated in one light zone. Just one lantern is necessary to achieve this: it should be attached to tree B. On the right, at most four trees can be illuminated in one light zone; the most efficient way to do is is attaching lanterns to trees C and E. In both cases, tree D is situated too far from the other trees to be able to form a light zone with them.
For each test case, the output contains one line with two integer numbers, separated by a space. The first number indicates the size of the largest connected light zone (in terms of illuminated trees) that can be created, the second number indicates the minimal amount of lanterns needed to illuminate all these trees.
2 2 4 0 0 2 0 -2 0 0 6 2 5 0 0 1 0 -1 0 0 6 4 -2
3 1 4 2