Algorithms-on-graphs--Adding-Exits-to-a-Maze
Problem Introduction Now you decide to make sure that there are no dead zones in a maze, that is, that at least one exit is reachable from each cell. For this, you find connected components of the corresponding undirected graph and ensure that each component contains an exit cell. Problem Description Task. Given an undirected graph with π vertices and π edges, compute the number of connected components in it. Input Format. A graph is given in the standard format. Constraints. 1 β€ π β€ 103, 0 β€ π β€ 103. Output Format. Output the number of connected components.