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

23493번 - Back and Forth 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 256 MB34171669.565%

문제

There are $n$ stations and $m$ directed roads between them.

One day, Chiaki is going from the $s$-th station to the $t$-th station, then back to the $s$-th station. Doing so, he needs to buy tickets for stations he passes. The price the tickets for the $i$-th station is $p_i$. If Chiaki buys a ticket for the $i$-th station, he can passes the station as many times as he wants. Find the minimum price of tickets to buy.

입력

There are multiple test cases. The first line of the input contains an integer $T$ (1ドル \leq T \leq 200$) indicating the number of test cases. For each test case:

The first line of each test case contains four integers $n,ドル $m,ドル $s$ and $t$ (1ドル \leq n \leq 200,ドル 0ドル \leq m \leq n \times (n - 1),ドル 1ドル \leq s, t \leq n$). The second line contains $n$ integers $p_1, p_2, \dots, p_n$ (1ドル \leq p_i \leq 100$). The $i$-th of the following $m$ lines contains two integers $a_i$ and $b_i,ドル which denote a road from the $a_i$ station to the $b_i$-th station (1ドル \leq a_i, b_i \leq n$).

The sum of all $n$ does not exceed 200ドル$.

출력

For each test case, output an integer denoting the answer. Print $-1$ for no solution.

제한

예제 입력 1

3
4 5 1 4
1 1 1 1
1 2
2 3
3 1
4 2
3 4
4 4 1 2
1 1 1 1
1 2
2 3
3 4
4 1
4 8 1 3
1 100 1 1
1 2
2 1
2 3
3 2
1 4
4 1
3 4
4 3

예제 출력 1

4
4
3

힌트

출처

Contest > Open Cup > 2019/2020 Season > Stage 18: Grand Prix of Bytedance G번

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

출처

대학교 대회

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

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