#graph103. 最大半连通子图
最大半连通子图
Largest Semi-Connected Subgraph
Problem Source
ZJOI2007
Problem Description
A directed graph is called semi-connected if: for all , either or , i.e. for any two vertices in the graph there is a directed path from to or from to .
If satisfies and consists of all edges in related to , then is called an induced subgraph of . If is an induced subgraph of and is semi-connected, then is a semi-connected subgraph of .
If is the semi-connected subgraph of containing the most vertices, then is the largest semi-connected subgraph. Given a directed graph , find , the number of vertices in the largest semi-connected subgraph of , and , the number of different largest semi-connected subgraphs. Since may be large, only output .
Input Format
The first line contains three integers . are the number of vertices and edges of ; the meaning of is as above.
The next lines each contain two positive integers , representing a directed edge .
There are no multiple edges in the input. .
Output Format
Two lines in total. The first line contains one integer ; the second line contains .
Sample Input
6 6 20070603
1 2
2 1
1 3
2 4
5 6
6 4
Sample Output
3
3