Wizard and Date
All submissions for this problem are available.
In the kingdom of Qwan there lived a wizard named Omen. Omen has got a date today. He knows that girls love roses so he decided to give her a rose. But today, Omen's garden has no fresh rose so the only option left for Omen is to buy a new rose. He knows that the rose shop is situated on the road R and he has arranged his date on the cafe situated on road D. But he wants to be on time and was wondering in what minimum time can he reach the cafe. Help Omen in doing so. The city has N roads and time taken from ith to jth road is provided for you.
The first line contains an integer T, denoting number of test cases. The first line of each test case contains an integer N, denoting the number of roads in the city. Next N lines will contain a list of N separated numbers. The jth number in the ith line denotes the time taken from ith road to jth road directly. After these N lines, the next line contains three space separated integers C, R and D, which are the locations of Omen, the rose shop and the cafe as described in the problem statement.
For each test case, output a single number denoting the minimum time taken by Omen to reach from C to R to D.
- 1 ≤ T ≤ 10
- 1 ≤ N ≤ 200
- 1 ≤ Time take to go directly from ith to jth road ≤ 109
- 1 ≤ C,R,D ≤ N
Input: 1 5 0 1 2 1 2 1 0 3 2 1 1 2 0 3 3 1 1 1 0 2 3 2 3 3 0 1 3 4 Output: 4
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS|
Fetching successful submissions