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

11267번 - Adjoin the Networks 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB163524432.593%

문제

One day your boss explains to you that he has a bunch of computer networks that are currently unreachable from each other, and he asks you, the cable expert’s assistant, to adjoin the networks to each other using new cables. Existing cables in the network cannot be touched.

He has asked you to use as few cables as possible, but the length of the cables used does not matter to him, since the cables are optical and the connectors are the expensive parts. Your boss is rather picky on cable usage, so you know that the already existing networks have as few cables as possible.

Due to your humongous knowledge of computer networks, you are of course aware that the latency for an information packet travelling across the network is proportional to the number of hops the packet needs, where a hop is a traversal along a single cable. And since you believe a good solution to your boss’ problem may earn you that long wanted promotion, you decide to minimise the maximum number of hops needed between any pair of network nodes.

입력

On the first line, you are given two positive integers, the number 1 ≤ c ≤ 105 of computers and the number 0 ≤ l ≤ c − 1 of existing cables. Then follow l lines, each line consisting of two integers a and b, the two computers the cables connect. You may assume that every computer has a unique name between 0 and n − 1.

출력

The maximum number of hops in the resulting network.

제한

예제 입력 1

6 4
0 1
0 2
3 4
3 5

예제 출력 1

3

예제 입력 2

11 9
0 1
0 3
0 4
1 2
5 4
6 4
7 8
7 9
7 10

예제 출력 2

4

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Nordic Collegiate Programming Contest > NCPC 2015 A번

  • 문제를 만든 사람: Markus S. Dregi, Pål G. Drange
(追記) (追記ここまで)

출처

대학교 대회

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

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