|
||||||||||
CRB and RoadsTime Limit: 12000/6000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 628 Accepted Submission(s): 281 Problem Description There are $N$ cities in Codeland. The President of Codeland has a plan to construct one-way roads between them. His plan is to construct $M$ roads. But CRB recognized that in this plan there are many redundant roads. So he decided to report better plan without any redundant roads to President. Help him! The road ($u$, $v$) is redundant if and only if there exists a route from $u$ to $v$ without using it. Input There are multiple test cases. The first line of input contains an integer $T$, indicating the number of test cases. For each test case: The first line contains two integers $N$ and $M$ denoting the number of cities and the number of roads in the President¡¯s plan. Then $M$ lines follow, each containing two integers $u$ and $v$ representing a one-way road from $u$ to $v$. 1 ¡Ü $T$ ¡Ü 20 1 ¡Ü $N$ ¡Ü 2 * $10^{4}$ 1 ¡Ü $M$ ¡Ü $10^{5}$ 1 ¡Ü $u$, $v$ ¡Ü $N$ The given graph is acyclic, and there are neither multiple edges nor self loops. Output For each test case, output total number of redundant roads. Sample Input
Sample Output
Author KUT£¨DPRK£© Source | ||||||||||
|