|
||||||||||
ThievesTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 1861 Accepted Submission(s): 887 Problem Description In the kingdom of Henryy, there are N (2 <= N <= 100) cities, with M (M <= 10000) two-direct ways connecting them. A group of thieves from abroad plan to steal the metropolitan museum in city H (It has not been demolished). However, the brave, brilliant, bright police in the kingdom have known this plan long before, and they also plan to catch the thieves. The thieves are in the city S at present. The police try to catch them on their way from S to H. Although the thieves might travel this way by more than one group, our excellent police has already gather the statistics that the number of the people needed in city I (1<=I<=N) to arrest the thieves. The police do not want to encounter the thieves in either city S or city H. The police finish the task with the minimum number of people. Do you know the exact number? Input The first line contains an integer T (T <= 10), indicating the number of the test cases. The first line of each test case has four integers: N, the number of the cities; M, the number of the roads; S (1<=S<=N), the label of city S; H (1<=T<=N, S¡ÙH), the label of city H. The second line contains N integers, indicating the number of people needed in each city. The sum of these N integers is less than 10000. Then M lines followed, each containing two integers x and y, indicating that there is a two-direct roads between city x and y. Notices that no road between city S and H. A blank line is followed after each test case. Output For each test case, output a single integer in a separate line, indicating the minimum number of people the police used. Sample Input
Sample Output
Source | ||||||||||
|