Critical Road
시간 제한1초메모리 제한2048 MB
노드 1에서 모든 노드에 도달할 수 있는 DAG가 주어질 때, 각 노드 i로 가는 모든 경로에 포함되는 간선의 개수를 구한다.
문제
The City of ICPC is preparing for a party for its anniversary. As the mayor of the city, you would like to hold a parade in each of the districts in the city.
The parade route can be represented as a Directed Acyclic Graph. There are nodes (numbered from to ) that represent the districts in the city. There are directed edges (numbered from to ) that represent the one directional roads. By using road , the parade can move from district to , but not the other way around. It is known that all districts can be visited by the parade from the City Center, which resides in district .
A road is -critical if the road is used in all paths from district to district . It is possible for a road to be -critical for several values of . You want to assess the number of -critical roads for each , as they are pivotal for the parade.
For each that satisfies , determine the number of -critical roads.
입력
The first line consists of two integers (; ).
Each of the next lines consists of two integers (). The edges form a directed acyclic graph, and every node can be visited from node . Furthermore, there will be no multi-edges, i.e., there will be at most one edge that directs two nodes.
출력
Output integers in a single line. Each of the integers represents the number of -critical roads.