#P9079. [PA 2018] Heros
[PA 2018] Heros
Problem Description
This problem is translated from PA 2018 Round 2 Heros.
Given a directed acyclic graph with nodes and directed edges.
You need to delete nodes and all edges incident to them, so that the length of the longest path in the graph is as small as possible.
Input Format
The first line contains three integers , , and .
The next lines each contain two integers and , indicating that there is a directed edge from node to node .
Output Format
Output one integer in one line, the minimum possible length of the longest path in the graph.
6 5 1
1 3
2 3
3 4
4 5
4 6
2
3 3 3
1 2
1 3
2 3
0
Hint
Explanation for Sample 1
After deleting node , the length of the longest path in the graph is . This is the minimum value we can achieve. You can verify that among all possible choices, the minimum possible longest-path length is .

Constraints
This problem uses bundled testdata.
For of the testdata:
Translated by ChatGPT 5