Blockade
Time limit1sMemory limit128 MB
Given a directed graph, find the minimum number of edges whose removal disconnects server 1 from server n.
- Level
Medium7 of 10
- Topics
- Graph, Shortest path, BFS
- Solved
- No attempts yet
Problem
The internet of Bytotia is a network of servers joined by one-way links. An attacker wants to cut off every route from server 1 to server . The attacker can plant a trap on any link, and when a trap goes off it destroys the single link it sits on. The attacker uses as few traps as possible while still guaranteeing that no message can travel from server 1 to server . Find that minimum number of traps.
Input
The first line contains two integers and (): the number of servers and the number of links. Servers are numbered from to . Each of the next lines contains two integers and (, ), describing a one-way link from server to server . There is at most one direct link between any two servers.
Output
Print a single integer: the minimum number of links that must be destroyed so that server 1 can no longer reach server .