Hi! I can’t seem to figure out the error in the logic for this code. It seems pretty close to the editorial given. Could anyone just give me any direction or even a test case for which this would fail? I tried both, the DFS and the BFS implementation. Below is the link for the BFS implementation.

You should print long long variable using specifier “%lld”. Or just use cout.
It is fine to mix scanf and cout.

Also your implementation appears to be too slow. It gets TLE for some cases.

1 Like

Thanks a lot… :slight_smile: