#P6134. [JSOI2015] 最小表示
[JSOI2015] 最小表示
Description
Given a directed graph with vertices (each vertex is numbered from to ) and edges, JYY found that if some edges are deleted from the graph, the connectivity of the original graph may change; meanwhile, there are also some edges such that deleting them will not change the connectivity of the graph.
JYY wants to know: if we want to keep the connectivity between any two vertices in the original graph unchanged, what is the maximum number of edges we can delete?
To simplify the workload, this time JYY guarantees that the given directed graph is a directed acyclic graph (DAG) (JYY: after last year’s problem, everyone knows that problems on arbitrary directed graphs can eventually be transformed into problems on DAGs, so this year JYY simply made it easier).
Input Format
The first line contains two positive integers and .
The next lines each contain two positive integers and between and , indicating that there is a directed edge from to in the graph.
The input guarantees that between any two vertices, there is at most one edge.
Output Format
Output one line containing one integer, which is the maximum number of edges that JYY can delete.
5 6
1 2
2 3
3 5
4 5
1 5
1 3
2
Hint
Sample Explanation
One valid plan is to delete and . It is easy to prove that there is no better answer than .
Constraints
For of the data, , .
Translated by ChatGPT 5
京公网安备 11011102002149号