Title Link: http://acm.hdu.edu.cn/status.php?user=l1526789512&pid=2112&status=5
HDU Today
Time limit:15000/5000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 22918 Accepted Submission (s): 5483
Problem description through the brocade SAC Help, Sea East group finally passed the crisis, from now on, HDU development has been downwind, to 2050 years, the group has been quite scale, said to enter the Qianjiang pork economic Development Zone 500 strong. At this time, Xhd couple also retreated to the second line, and in the beautiful scenery of Zhuji knots Pu Zhen Tao Yao bought a house, began to comfort old age.
This lived for a period of time, Xu always to the local traffic still do not know very much. Sometimes very depressed, want to go to a place and do not know what bus to take, where to change, where to get off (in fact, Xu always own a car, but must have fun with the people, this is Xu General character).
Xu always asks the lame English question: Can you help me? Look at his confused and helpless eyes, enthusiastic can you help him?
Please help him to arrive at his destination in the shortest possible time (assuming that each bus stops at starting point and terminus and is open at all times).
Input data has multiple groups, the first row of each group is the total number of buses N (0<=n<=10000);
The second line has the location of the total Xu, start, his destination end;
Then there are n rows, each with the station name S, the station name E, and the time integer T (0<t<100) from S to E (each place name is a string with a length of not more than 30).
Note: No more than 150 place names in a set of data.
If N==-1, indicates the end of the input.
Output if Xu always arrives at the destination, outputs the shortest time; otherwise, output "-1".
Sample Input6xiasha Westlakexiasha Station 60xiasha Shoppingcenterofhangzhou 30station Westlake 20ShoppingCenterofHangZhou supermarket 10xiasha supermarket 50supermarket Westlake 10-1
Sample output50hint:the Best Route Is:xiasha->shoppingcenterofhangzhou->supermarket->westlake although occasionally lost, But because of your help * * and * * Still live a happy life. --the whole ending--the idea: a little pit when the map is built. Floyd and Dijkstra after the map was built. Map using the maps in the STL. Map<string,int> m;m.clear (); Emptying can have m[a] this usage; M.begin (); Returns the iterator M.end () of the first element in the map; Returns the iterator M.find () of the last element in the map; If an iterator is found that returns to the element, the iterator that returns the last element distance function//can be found by two iterators more things about map still need to be learned. Floyd and Dijkstra
Hdu_2112_ Shortest circuit