Set 104Question 32

Tanvir's Network Reach Checker

HardWritten in CMust finish in 3 seconds

Tanvir is mapping the internal network at a school fair and wants the shortest hop-distance from the main server to every other node.

What your program reads

Line1: N M S. Next M lines: u v.

What your program prints

N distances from S (or -1 if unreachable).

Limits

1 ≤ N ≤ 10^5

Example input

4 3 1
1 2
2 3
3 4

Expected output

0 1 2 3
main.c

Your work is saved in this browser as you type.

Loading editor…
Input for Run

Run tries your code on the input above and shows what it prints. Submit checks your output against every test, including hidden ones.

Shortcut: Ctrl + Enter sends it to the judge.

Tanvir's Network Reach Checker · DIU ContestHub