#C8288. Taco Network Communication

    ID: 52253 Type: Default 1000ms 256MiB

Taco Network Communication

Taco Network Communication

You are given a network of n computers and m communication links connecting them. Each communication link connects two computers in both directions. Your task is to determine whether there exists a path between a given source computer and a destination computer.

Approach: You can solve this problem by modeling the network as an undirected graph and performing a Breadth-First Search (BFS) from the source node. If the destination is reached during the BFS, output Yes; otherwise, output No.

Input/Output: The input should be read from standard input (stdin) and the output should be printed to standard output (stdout).

inputFormat

The first line contains two integers n and m — the number of computers and the number of communication links respectively. The next m lines each contain two integers u and v, representing an undirected edge between computers u and v. The last line contains two integers s and d, representing the source and destination computers respectively.

outputFormat

Print "Yes" if there exists a path from the source computer to the destination computer; otherwise, print "No".## sample

6 7
1 2
2 3
3 4
4 5
5 6
1 6
3 5
1 5
Yes