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

20334번 - Family Fares 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 512 MB104524953.261%

문제

After a long time apart, your family will gather next year for a reunion in an idyllic village in the centre of the country. Since everybody lives apart, most will need to travel by train.

You are in charge of finding the best deal on tickets. Everyone must take an optimal route, that is to say they may only travel a route if no other route is shorter.

Two types of ticket are available: individual or group. All tickets come with a start and destination between which to travel. Individual tickets are unlimited and the price is equal to the shortest distance in kilometres between stations.

Group tickets are more complicated. First, you may only buy at most one and it must be for a set list of people. There is no limit to the number of people named, but all must be present. The ticket is priced according to the number of named persons.

Figure F.1: Sample 2. Group or individual tickets are shown by thick or thin lines, respectively.

입력

  • One line with four integers: $n$ (2ドル \le n \le 1000$), the number of stations, $m$ ($n-1 \le m \le 10^5$), the number of connections between stations, $p$ (1ドル \le p \le 100$), the number of family members, and $g$ (1ドル \le g \le 10^6$), the cost per person of a group ticket.
  • One line with $p$ integers $v_i$ (1ドル \le v \le n$), meaning that family member $i$ starts at station $v_i$.
  • $m$ further lines, each with three integers $a,ドル $b,ドル and $c$ (${1 \le a,b \le n},ドル $a\neq b,ドル and ${1 \le c \le 10^6}$), indicating that there is a bidirectional connection between stations $a$ and $b$ with a length of $c$ kilometres.

Each pair of distinct stations has at most one direct connection and every station can be reached from any other station. Station number 1ドル$ serves the idyllic village.

출력

Output the total amount you must spend so that every family member can travel from their starting station to the idyllic village.

제한

예제 입력 1

6 5 3 10
4 5 6
1 2 10
2 3 10
3 4 10
4 5 2
4 6 3

예제 출력 1

35

예제 입력 2

7 7 4 10
5 4 4 7
1 2 100
2 3 100
3 4 10
1 5 80
3 5 30
3 6 10
6 7 5

예제 출력 2

145

예제 입력 3

4 5 2 10
2 4
1 2 20
2 4 5
1 3 20
3 4 5
1 4 30

예제 출력 3

25

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > The UK & Ireland Programming Contest > UKIEPC 2020 F번

ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2020 F번

  • 문제를 만든 사람: Boas Kluiving
(追記) (追記ここまで)

출처

대학교 대회

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

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