#K76127. Count Unreachable Servers
Count Unreachable Servers
Count Unreachable Servers
You are given an undirected graph representing a network of (n) servers numbered from 1 to (n) and (m) bidirectional connections between them. A starting server (s) is also provided. Your task is to compute the number of servers that are not reachable from server (s).
In other words, starting from (s), count how many servers cannot be visited using any sequence of the given connections. Use standard graph traversal methods such as Breadth-First Search (BFS) or Depth-First Search (DFS) to solve the problem.
inputFormat
The input is read from standard input and has the following format:
(n) (m) (s) — three integers where (n) is the number of servers, (m) is the number of connections, and (s) is the starting server.
Then follow (m) lines, each containing two integers (u) and (v) representing an undirected edge between server (u) and server (v).
outputFormat
Output a single integer to standard output: the number of servers that are not reachable from the server (s).## sample
6 5 1
1 2
1 3
2 4
2 5
5 6
0