Logo
(追記) (追記ここまで)

27617번 - Road To Savings 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB71464570.312%

문제

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 $n$ $m$ $a$ $b$ ($n, a, b \leq 100, a \neq b$) where $n$ indicates the number of intersections in the town (numbered 1ドル$ to $n$), $m$ is the number of roads connecting intersections, and $a$ and $b$ are the intersections where the mayor's house and office are located, respectively. Following this are $m$ lines, each containing a triplet of numbers $i_1$ $i_2$ $\ell$ (1ドル \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 $i_1$ and $i_2$ with length $\ell$. At most one road exists between any two intersections and at least one path exists between $a$ and $b$.

출력

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

예제 출력 1

3

예제 입력 2

4 5 1 4
1 2 1
1 3 2
1 4 1
4 2 1
3 4 1

예제 출력 2

5

힌트

출처

ICPC > Regionals > North America > East Central North America Regional > 2022-2023 East Central Regional Contest I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /