Comments
0

To make it clear, "the tree" here means "a tree that is both a BFS tree rooted at x and y at the same time". So by definition, the length of the (one and only) path from x to y on that tree must be equal to the length of the shortest path from x to y in the original graph.

so glad that codeforces is back here thank you so much for this great website!!