All Submissions


"Unix is user friendly. It just happens to be very selective about who it decides to make friends with."

ACM is planning to organize a UNIX based event CodeShell soon after mid-sems. So, Nimesh Ghelani, the Secretary, has been assigned the job of making sure that notices have been put up in every hostel. So, he sets out from R&D building with S copies of notices, where S is the number of hostels in BIT Mesra. He has to go S hostels, complete the formalities at every hostel (which takes negligible time), and return back to R&D to report that the job is done. Nims intends to find the optimal route so as to minimize the time and energy wasted on this task.

He has an BIT map data which lists N landmarks numbered from 0 to N-1. Out of these N landmarks, S of them are hostels. R&D is marked as landmark 0. There are M routes which connect different landmarks. He asks for your help to find the optimal route for him because this trivial route finding is not worth the time of such an excellent coder.

Input Specification
Input consists of number of test cases. Read till EOF.
Every test case starts with two integers N and M on the first line. M lines follow containing two landmark and distance between them.(Li1,Li2,Di).Next line contains single integer S. S lines follow listing the landmark numbers (Hi) for each hostel.
Every test case is followed by a blank line.

Output Specifications
Output single integer for every test case which is the minimum distance Nims has to travel.

Constraints
No. of test cases <= 15
0 <= Li1,Li2 < N
0 <= S <= 10
1 <= Hi < N

For 2/3rd test cases
1 <= N,M <= 10
1 <= Di <= 10

For 1/3rd test cases
1 <= N,M <= 100000
1 <= Di <= 100000

All routes between the landmarks are bidirectional.

Sample Test Case
Input
3 3
0 1 2
1 2 4
2 0 1
2
1
2

4 6
0 1 1
1 2 1
2 3 1
3 0 1
0 2 5
1 3 5
3
1
2
3

Output
6
4


Problem Setter : Shikhar Sharad

Languages: AWK,Bash,Brain,C,C++,Java,C#,JavaScript,Pascal,Perl,PHP,Python,Python3,Ruby,Text

Time Limit: 5 Second(s)
Score: 100 Point(s)
Input File Limit: 50000 Bytes

Submit

Login to post clarification.

No Clarifications.

Contest

Mode Judge

Passive

Online

Overall Rankings

RankNameScore
1xyz0
2Ams0
3TIP0
4team420
5xyzz0
6asdasdasd0
7abcd0
8khankhan0
9Gabriel0
10gigel0