Back
Close

Pathfinder

Statement

 Goal

Pathfinding in 15 minutes! Can you do it? ...

The Rules are simple:
1. There are N NODES number from 0 to N-1
2. There are L LINKS connecting the nodes
3. Each link is described as N1 - N2, meaning:
(i) - You can go from N1 to N2,
(ii) - You can also go from N2 to N1
4. You will be given the STARTING point S and ENDING point E

You have To:
Display minimum TIME to reach E from S

Best of Luck! The clock is ticking...
Input
Line 1: An integer N, the number of nodes
Line 2: An integer L, the number of links
Next L lines: 2 integers N1 and N2, the 2 nodes of a link
Next Line: 2 integers S and E, the starting and ending points
Output
Line 1: An integer T, the minimum time taken to reach E from S
Constraints
Example
Input
4
4
0 1
0 2
1 3
2 3
0
3
Output
2

Game modes
Fastest

Test cases
Test 1 Test
Input
4 4 0 1 0 2 1 3 2 3 0 3
Output
2

Validator 1 Validator
Input
4 4 0 1 0 2 1 3 2 0 0 3
Output
2

Test 2 Test
Input
2 1 0 1 0 1
Output
1

Validator 2 Validator
Input
2 1 1 0 0 1
Output
1

Test 3 Test
Input
12 23 11 6 0 9 1 2 0 1 10 1 11 5 2 3 4 5 8 9 6 7 7 8 0 6 3 4 0 2 11 7 0 8 0 4 9 10 0 5 0 7 0 3 0 10 5 6 11 1
Output
3

Validator 3 Validator
Input
12 23 11 6 0 9 1 2 0 1 10 1 11 5 2 3 4 5 8 9 6 7 7 8 0 6 3 4 0 2 11 7 0 8 0 4 9 10 0 5 0 7 0 3 0 10 5 6 1 11
Output
3

Test 4 Test
Input
38 79 28 36 0 2 3 34 29 21 37 35 28 32 0 10 37 2 4 5 13 14 34 35 27 19 28 34 30 31 18 26 0 9 7 8 18 24 18 23 0 5 16 17 29 30 10 11 0 12 15 16 0 11 0 17 18 22 23 24 0 7 35 23 22 23 1 2 0 13 18 27 25 26 32 33 28 31 24 25 28 35 21 22 4 33 28 29 36 22 18 25 37 23 18 21 5 6 19 20 0 14 35 36 9 10 0 6 20 21 0 3 33 34 14 15 28 33 11 12 12 13 17 1 18 19 36 29 0 4 0 15 0 1 18 20 2 3 0 16 8 9 0 8 26 27 28 30 3 4 31 32 6 7 37 1 37 24 35 2 14 22
Output
5

Validator 4 Validator
Input
38 79 28 36 0 2 3 34 29 21 37 35 28 32 0 10 37 2 4 5 13 14 34 35 27 19 28 34 30 31 18 26 0 9 7 8 18 24 18 23 0 5 16 17 29 30 10 11 0 12 15 16 0 11 0 17 18 22 23 24 0 7 35 23 22 23 1 2 0 13 18 27 25 26 32 33 28 31 24 25 28 35 21 22 4 33 28 29 36 22 18 25 37 23 18 21 5 6 19 20 0 14 35 36 9 10 0 6 20 21 0 3 33 34 14 15 28 33 11 12 12 13 17 1 18 19 36 29 0 4 0 15 0 1 18 20 2 3 0 16 8 9 0 8 26 27 28 30 3 4 31 32 6 7 37 1 37 24 35 2 22 14
Output
5

Solution language

Solution

Stub generator input