BFS Path

0

0 votes
Easy
Problem

In question 1, print the path instead of the cost. Print “NIL” if no path exists.

 

Sample Input

1

7 14

0 5

5 0

0 1

1 0

1 2

2 1

2 5

5 2

0 3

3 0

3 4

4 3

4 5

5 4

 

Sample Output

0

0 1

0 5 2

0 3

0 5 4

0 5

NIL

 

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?