P9079 [PA 2018] Heros

Description

**This problem is translated from [PA 2018](https://sio2.mimuw.edu.pl/c/pa-2018-1/dashboard/) Round 2 [Heros](https://sio2.mimuw.edu.pl/c/pa-2018-1/p/her/).** Given a directed acyclic graph with $n$ nodes and $m$ directed edges. You need to delete $k$ 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 $n$, $m$, and $k$. The next $m$ lines each contain two integers $x$ and $y$, indicating that there is a directed edge from node $x$ to node $y$.

Output Format

Output one integer in one line, the minimum possible length of the longest path in the graph.

Explanation/Hint

#### Explanation for Sample 1 After deleting node $4$, the length of the longest path in the graph is $2$. This is the minimum value we can achieve. You can verify that among all possible choices, the minimum possible longest-path length is $2$. ![](https://cdn.luogu.com.cn/upload/image_hosting/6sgk5qmj.png) ------------ #### Constraints **This problem uses bundled testdata.** For $100\%$ of the testdata: - $1 \le n \le 300$ - $0 \le m \le 400$ - $0 \le k \le \min(n,4)$ - $1 \le x < y \le n$ Translated by ChatGPT 5