Logo
(追記) (追記ここまで)

29780번 - Illumination Optimization 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
10 초 (추가 시간 없음) 1024 MB44252153.846%

문제

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 $\mathbf{M}$ meters that goes from west to east. The $x$-th meter is a point that is $x$ meters to the east of the western end of the freeway. If a street light is located at the $x$-th meter, and a lightbulb with an illumination radius of $\mathbf{R}$ meters is installed on it, then the street light illuminates the segment of freeway starting at the $\max(0, x - \mathbf{R})$-th meter and ending at the $\min(\mathbf{M}, x + \mathbf{R})$-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 $\mathbf{M},ドル the illumination radius of the new lightbulbs $\mathbf{R}$ 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, $\mathbf{T}$. $\mathbf{T}$ test cases follow. Each test case consists of two lines. The first line contains three integers $\mathbf{M},ドル $\mathbf{R},ドル and $\mathbf{N}$: 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 $\mathbf{N}$ sorted integers $\mathbf{X_1}, \mathbf{X_2}, \dots, \mathbf{X_N}$ representing the meters of the freeway where street lights are located.

출력

For each test case, output one line containing Case #x: y, where $x$ is the test case number (starting from 1) and $y$ 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, $y$ should be IMPOSSIBLE instead.

제한

  • 1ドル \le \mathbf{T} \le 100$.
  • 1ドル \le \mathbf{M} \le 10^9$.
  • 1ドル \le \mathbf{R} \le 10^9$.
  • 0ドル \le \mathbf{X_1}$.
  • $\mathbf{X_i} \lt \mathbf{X_{i+1}},ドル for all $i$.
  • $\mathbf{X_N} \le \mathbf{M}$.

Test Set 1 (4점)

  • 1ドル \le \mathbf{N} \le 10$.

Test Set 2 (10점)

  • 1ドル \le \mathbf{N} \le 10^5$.

예제 입력 1

3
10 3 3
2 7 9
10 2 3
2 7 9
10 2 4
2 3 7 9

예제 출력 1

Case #1: 2
Case #2: IMPOSSIBLE
Case #3: 4

힌트

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 $[0, 5]$ and $[4, 10],ドル the entire freeway ($[0, 10]$) 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 4ドル$-th and 5ドル$-th meters would still not be illuminated.

For Sample Case #3 Onyaomale has an additional street light at the 3ドル$-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.

출처

Contest > Google > Code Jam > Google Code Jam Farewell Round > Round A B번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /