#P2416. Martian Cat's Puff Quest
Martian Cat's Puff Quest
Martian Cat's Puff Quest
The Martian Cat has finally reached Pluto after much effort. On Pluto, he discovers that there are \(N\) cities and \(M\) undirected roads. He is on a quest to meet the Martian Rabbit, and he has heard that some roads have delicious puffs dropped on them, which he plans to collect and gift to the Rabbit. However, due to the mysterious interaction between his Martian aura and Pluto, once the Cat travels a road, that road can no longer be used.
Given the starting positions of the Martian Cat and the Martian Rabbit, determine whether the Rabbit can get to taste the puffs, i.e. whether there exists a simple path from the Cat's starting city to the Rabbit's starting city.
Note: A simple path is a path in which no edge is used more than once.
inputFormat
The first line of input contains four integers \(N, M, S, T\) where \(N\) is the number of cities, \(M\) is the number of undirected roads, \(S\) is the starting city of the Martian Cat, and \(T\) is the city where the Martian Rabbit is located.
Each of the next \(M\) lines contains two integers \(u\) and \(v\), indicating that there is an undirected road connecting city \(u\) and city \(v\).
Assume cities are numbered from 1 to \(N\).
outputFormat
Output a single line containing Yes
if there exists a simple path from city \(S\) to city \(T\); otherwise, output No
.
sample
3 2 1 3
1 2
2 3
Yes