|
||||||||||
Harry Potter and the Forbidden ForestTime Limit: 5000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 3027 Accepted Submission(s): 1017 Problem Description Harry Potter notices some Death Eaters try to slip into Castle. The Death Eaters hide in the most depths of Forbidden Forest. Harry need stop them as soon as. The Forbidden Forest is mysterious. It consists of N nodes numbered from 0 to N-1. All of Death Eaters stay in the node numbered 0. The position of Castle is node n-1. The nodes connected by some roads. Harry need block some roads by magic and he want to minimize the cost. But it¡¯s not enough, Harry want to know how many roads are blocked at least. Input Input consists of several test cases. The first line is number of test case. Each test case, the first line contains two integers n, m, which means the number of nodes and edges of the graph. Each node is numbered 0 to n-1. Following m lines contains information about edges. Each line has four integers u, v, c, d. The first two integers mean two endpoints of the edges. The third one is cost of block the edge. The fourth one means directed (d = 0) or undirected (d = 1). Technical Specification 1. 2 <= n <= 1000 2. 0 <= m <= 100000 3. 0 <= u, v <= n-1 4. 0 < c <= 1000000 5. 0 <= d <= 1 Output For each test case: Output the case number and the answer of how many roads are blocked at least. Sample Input
Sample Output
Author aMR @ WHU Source | ||||||||||
|