HardGraphs2000 ms256 MB
Campus Paths
Given an undirected graph of rooms and paths, count how many rooms can be reached from room 1.
Statement
Given an undirected graph of rooms and paths, count how many rooms can be reached from room 1.
Input
First line: `n m`. Next `m` lines: edges `a b`.
Output
Print the number of reachable rooms from room 1.
Constraints
- `1 <= n <= 100000`
Examples
Example 1
Input
5 4
1 2
2 3
4 5
3 1Output
3Rooms 1, 2, and 3 are connected.
Sample runs use visible examples. Full submissions are checked securely on the server, and private test cases are not shown in the browser.