Hide

Problem B
Bots

Tom has built a network of $\mathbf{N}$ bots numbered $0, 1, 2, 3, \dots \mathbf{N}-2, \mathbf{N}-1$. Not all bots can talk to each other. Each bot is capable of signalling zero, one or more other bots (but not signal itself).

If bot $\mathbf{A}$ wants to send a message to bot $\mathbf{B}$, it can:

  1. Signal bot $\mathbf{B}$ directly, or

  2. Signal some other bot $\mathbf{C}$ to send a message to bot $\mathbf{B}$ (assuming there is a path in which a chain of signals can reach $\mathbf{B}$)

Each bot can either be a solobot, or is part of one botnet, but will NOT be both, and will NOT be part of multiple botnets.

A solobot $\mathbf{S}$ is a bot in which there is NO other bot $\mathbf{T}$ in the network of all bots for which $\mathbf{S}$ and $\mathbf{T}$ can send a message to each other.

A botnet $\mathbf{E}$ is a set of at least 2 bots in which for every bot $\mathbf{X}$ in $\mathbf{E}$, and every bot $\mathbf{Y}$ in the network of all bots, $\mathbf{X}$ and $\mathbf{Y}$ can send a message to each other IF AND ONLY IF $\mathbf{Y}$ is also in $\mathbf{E}$.

Therefore bots in botnets can send a message to themselves (through other bots in the same botnet), but solobots cannot send a message to themselves.

Currently all of Tom’s bots are active, but Tom wants to put all of them into sleep mode. Tom will issue a program to some bot(s) to broadcast a message to every possible bot in the network instructing that bot to go into sleep mode. Bots can still send message when in sleep mode.

Find the minimum number of solobots and the minimum number of bots that are part of a botnet that Tom has to issue the program to, so that all bots go into sleep mode.

Input

The first line contains 2 integers $\mathbf{N}$ ($1 \le \mathbf{N} \le 99,999$) the number of bots and $\mathbf{M}$ ($0 \le \mathbf{M} \le 600,000$) the number of ordered pairs of bots ($\mathbf{P}$, $\mathbf{Q}$) in which $\mathbf{P}$ can signal $\mathbf{Q}$. All $\mathbf{M}$ ordered pairs will be distinct.

Each of the next $\mathbf{M}$ lines contains 2 integers $\mathbf{P}$ ($0 \le \mathbf{P} < \mathbf{N}$) and $\mathbf{Q}$ ($0 \le \mathbf{Q} < \mathbf{N}, \mathbf{P} \neq \mathbf{Q}$).

Output

A line containing 2 integers: the minimum number of solobots and the minimum number of bots part of a botnet respectively that must be issued the program.

Sample Input 1 Sample Output 1
4 2
0 1
1 3
2 0
Sample Input 2 Sample Output 2
4 4
0 1
1 0
1 3
2 3
1 1
Sample Input 3 Sample Output 3
9 10
0 1
1 2
1 3
2 0
3 4
5 3
5 6
6 5
7 3
8 7
1 2

Please log in to submit a solution to this problem

Log in