EIU ICPC Contest 2026 - I: Leaf Village Mission
Xem dạng PDF
Gửi bài giải
Điểm:
1,00
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
256M
Input:
stdin
Output:
stdout
Nguồn bài:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
In a special operation, Tang — the tactical commander of the Leaf Village — needs to deploy ninjas to eliminate ~n~ targets located at ~n~ different places, numbered from ~1~ to ~n~. These locations are connected by ~m~ directed roads.
Each ninja can start at any location, travel along the directed roads, and eliminate all targets at the locations visited along their route (a route can be arbitrary and may loop through locations multiple times).
To conserve resources, Tang wants to determine the minimum number of ninjas required to accomplish the mission and eliminate all ~n~ targets. Help Tang find this minimum number of ninjas!
Input
- The first line contains two integers ~n~ and ~m~ ~(1 \le n \le 1000, 0 \le m \le 10000)~ — the number of locations and directed roads, respectively.
- The next ~m~ lines each contain two integers ~u~ and ~v~ ~(1 \le u, v \le n, u \neq v)~ — representing a directed road from location ~u~ to location ~v~.
Output
- Print a single integer representing the minimum number of ninjas needed to complete the mission.
Sample Input 1
5 4
1 2
1 3
4 1
5 1
Sample Output 1
2
Sample Input 2
7 0
Sample Output 2
7
Sample Input 3
8 8
1 2
2 3
3 4
4 1
1 6
6 7
7 8
8 6
Sample Output 3
2
Bình luận