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

16536번 - Computer network 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB357722.581%

문제

A computer network comprises N computers, numbered from 0 to N-1. Each one, after receiving a message, passes it to some other computers. If a message from computer X can reach a computer Y, this does not necessarily mean that a message from computer Y reaches the computer X. The system administrators want to determine the minimum number of computers from which a message has to be sent in order to reach all the computers in the network.

For better transmission of messages, they believe that the network needs to be extended by adding new connections between some computers, so when sending a message from an arbitrary computer it will be distributed to all others. For this purpose, it is necessary to determine the minimum number of new connections to be added, so that each of the computers can be used as initial for distribution of messages.

Write a program cnet that finds the minimal number of computers from which a message needs to be sent in order to be distributed to all computers in the network and finds the minimum number of new connections that need to be added, in order to allow a message, sent from each of the computers, to reach every other computer in the network.

입력

The first line of the standard input contains two integers N and M, representing the number of computers and the number of connections between them. Each of the next M lines describe one available connection. The first number is the number of the computer sending the message, and the second number is the number of the computer receiving the message.

출력

On a single line of the standard output, the program outputs two integers - the minimum number of computers that are used as initial for distributing a message to the whole network and the minimum number of additional connections needed to extend the network in a way that a message sent from an arbitrary chosen computer, will reach all the others.

제한

  • 1 < N ≤ 1 600
  • 0 ≤ M ≤ 120 000

예제 입력 1

6 12
0 1
0 2
1 0
1 2
2 0
2 1
3 4
3 5
4 3
4 5
5 3
5 4

예제 출력 1

2 2

힌트

출처

Olympiad > International Autumn Tournament in Informatics > 2017 > Group B (Juniors) 3번

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

출처

대학교 대회

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

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