PivotOJ

Road To Savings

시간 제한: 1000ms메모리 제한: 1024MB출처: ICPC ECNA 2022-2023BOJ 27617

문제

Pat Wholes is in charge of road maintenance in Capitol City, and boy do those roads need maintenance. The road conditions are so poor that accidents have become almost a daily event, and the surviving public is in an uproar. Now while Pat would love to pave every road in the city, he also wants to keep his job. The cost of all that paving would certainly upset the mayor, who would just as certainly replace Pat if he spends too much. So now the decision is: which roads get paved and which don't? After thinking about this problem -- and his job security -- Pat came up with a bright idea: since the ultimate goal is to keep the mayor happy, he'll pave only those roads that are on a shortest path from the mayor's house to the mayor's office. There actually might be several ways for the mayor to drive to work that are equally short, but that should still leave plenty of roads that aren't on any of these paths and hence plenty of roads that don't need to be paved (hopefully). Pat's come down to your cubicle in the basement to ask you to determine the length of roads that don't need to be paved.

입력

Input starts with four positive integers nn mm aa bb (n,a,b100,abn, a, b \leq 100, a \neq b) where nn indicates the number of intersections in the town (numbered 11 to nn), mm is the number of roads connecting intersections, and aa and bb are the intersections where the mayor's house and office are located, respectively. Following this are mm lines, each containing a triplet of numbers i1i_1 i2i_2 \ell (1i1,i2n,i1i2,11001 \leq i_1, i_2 \leq n, i_1 \neq i_2, 1 \leq \ell \leq 100) indicating a two-way road exists between intersection i1i_1 and i2i_2 with length \ell. At most one road exists between any two intersections and at least one path exists between aa and bb.

출력

Output the total length of all roads that don't need to be paved.

예제

예제 1

입력
4 5 1 4
1 2 1
1 3 2
1 4 2
4 2 1
3 4 1
출력
3

예제 2

입력
4 5 1 4
1 2 1
1 3 2
1 4 1
4 2 1
3 4 1
출력
5
코드를 제출하려면 로그인하세요.