#P12947. [GCJ Farewell Round #1] Illumination Optimization
[GCJ Farewell Round #1] Illumination Optimization
题目描述
Onyaomale is leading a project to exchange the lightbulbs from street lights along a freeway from incandescent ones to LED lightbulbs that are both more energy-efficient and powerful. She started by taking all the old incandescent lightbulbs out, and is now focused on installing the new LED ones. Because the new lightbulbs are more powerful, Onyaomale thinks it is possible that some street lights are not necessary and she can save even more energy by not using them.
We model the freeway as a straight line measuring meters that goes from west to east. The -th meter is a point that is meters to the east of the western end of the freeway. If a street light is located at the -th meter, and a lightbulb with an illumination radius of meters is installed on it, then the street light illuminates the segment of freeway starting at the -th meter and ending at the -th meter, inclusive. Onyaomale needs to install lightbulbs in such a way that every point of the freeway is illuminated by at least one of them. Notice that this includes illuminating points that are not an integer number of meters away from the freeway endpoints. Street lights that are left without a lightbulb do not illuminate anything.
Given the length of the freeway in meters , the illumination radius of the new lightbulbs and the locations of all street lights, find the minimum number of lightbulbs Onyaomale needs to install to illuminate the whole freeway, or report that it is impossible to do so.
输入格式
The first line of the input gives the number of test cases, . test cases follow. Each test case consists of two lines. The first line contains three integers , , and : the length, in meters, of the freeway, the illumination radius, in meters, of the lightbulbs and the number of street lights, respectively. The second line of a test case contains sorted integers , , , representing the meters of the freeway where street lights are located.
输出格式
For each test case, output one line containing Case #x: y
, where is the test case number (starting from 1) and is the minimum number of lightbulbs Onyaomale needs to install to illuminate the whole freeway, if it is possible. If there is no way to illuminate the entire freeway using the current street lights, should be IMPOSSIBLE instead.
3
10 3 3
2 7 9
10 2 3
2 7 9
10 2 4
2 3 7 9
Case #1: 2
Case #2: IMPOSSIBLE
Case #3: 4
提示
Sample Explanation
In Sample Case #1, Onyaomale can illuminate the entire freeway by placing bulbs in the western-most and middle street lights only, leaving the eastern-most one unused. With these two lights covering and , the entire freeway is illuminated.
In Sample Case #2, Onyaomale has the same configuration as in Sample Case #1, but with weaker lightbulbs. In this case, there is no way for her to illuminate the entire freeway. In particular, even if all the street lights are lit, the middle point between the -th and -th meters would still not be illuminated.
For Sample Case #3 Onyaomale has an additional street light at the -th meter, compared to Sample Case #2, while all other conditions are the same. In this case, installing a lightbulb in every street light is the only way to have the entire freeway illuminated.
Limits
- $\mathbf{X}_{i} < \mathbf{X}_{i+1}, \text{ for all } i.$
Test Set 1 (4Pts, Visible Verdict)
Test Set 2 (10Pts, Visible Verdict)