#P7251. [JSOI2014] 强连通图
[JSOI2014] 强连通图
Description
JYY has recently become obsessed with strong connectivity in graphs. For any directed graph, JYY wants to add some edges to make the graph strongly connected. Now JYY is given a directed graph with vertices and edges, where the vertices are numbered from to .
JYY wants to know:
-
In the given graph, what is the maximum number of vertices that can be chosen such that every pair of these vertices is mutually reachable in the original graph?
-
In the given graph, what is the minimum number of edges that need to be added to make the graph strongly connected?
A directed graph is strongly connected if and only if for any two distinct vertices , there exist paths and .
Input Format
The first line contains two integers and .
The next lines each contain two integers and , indicating that there is a directed edge from to in the graph.
Output Format
Output two lines. The first line is the answer to the first question, and the second line is the answer to the second question.
4 3
1 4
2 3
2 4
1
2
Hint
Sample Explanation 1
For the first question, it is impossible to choose two vertices that are mutually reachable, so the answer is .
For the second question, one optimal way with the minimum number of added edges is and , so the answer is .
Constraints
For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号