|
||||||||||
WuKongTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2691 Accepted Submission(s): 996 Problem Description Liyuan wanted to rewrite the famous book ¡°Journey to the West¡± (¡°Xi You Ji¡± in Chinese pinyin). In the original book, the Monkey King Sun Wukong was trapped by the Buddha for 500 years, then he was rescued by Tang Monk, and began his journey to the west. Liyuan thought it is too brutal for the monkey, so he changed the story: One day, Wukong left his home - Mountain of Flower and Fruit, to the Dragon King¡¯s party, at the same time, Tang Monk left Baima Temple to the Lingyin Temple to deliver a lecture. They are both busy, so they will choose the shortest path. However, there may be several different shortest paths between two places. Now the Buddha wants them to encounter on the road. To increase the possibility of their meeting, the Buddha wants to arrange the two routes to make their common places as many as possible. Of course, the two routines should still be the shortest paths. Unfortunately, the Buddha is not good at algorithm, so he ask you for help. Input There are several test cases in the input. The first line of each case contains the number of places N (1 <= N <= 300) and the number of roads M (1 <= M <= N*N), separated by a space. Then M lines follow, each of which contains three integers a b c, indicating there is a road between place a and b, whose length is c. Please note the roads are undirected. The last line contains four integers A B C D, separated by spaces, indicating the start and end points of Wukong, and the start and end points of Tang Monk respectively. The input are ended with N=M=0, which should not be processed. Output Output one line for each case, indicating the maximum common points of the two shortest paths. Sample Input
Sample Output
Source | ||||||||||
|