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

5081번 - Constellations 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB100826888.312%

문제

One night, while camping out in the wide open spaces, Big Ed was looking at the stars. Now Ed never bothered to learn his constellations, but decided that grouping the stars was a reasonable thing to do after all. But Big Ed was going to do it in a sensible manner. He decided on the following simple rules:

  • Every star is in the same constellation as its closest neighbor.
  • If the closest neighbour is not unique, then the star and all its closest neighbours are in the same constellation.
  • If A is in the same constellation as B, then B is in the same constellation as A.
  • If A is in the same constellation as B, and B is in the same constellation as C, then A is in the same constellation as C.

For example, if the picture of the sky looked like the following:

Then there are 3 constellations: {1, 2, 3, 4, 5}, {6, 7, 8}, {9, 10}.

입력

Input will consist of a sequence of sky descriptions. Each begins with a single integer n: 0 < n ≤ 500 on a line, indicating the number of stars in the universe. The coordinates for the n stars follow as a pair x,y: 0 ≤ x ≤ 1000. A value of n = 0 indicates end of input.

출력

For each sky description, print a single line of the form

Sky s contains c constellations.

where s is the number of the sky description (starting at 1) and c is the number of constellations.

제한

예제 입력 1

10
0 1
16 3
1 0
2 7
9 0
4 1
2 2
8 1
9 3
15 5
5
10 10
10 11
20 10
20 11
15 5
0

예제 출력 1

Sky 1 contains 3 constellations.
Sky 2 contains 1 constellations.

힌트

출처

ICPC > Regionals > South Pacific > South Pacific Region > New Zealand Programming Contest > NZPC 2012 K번

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

출처

대학교 대회

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

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