| TheForces Round #38 (Tree-Forces) |
|---|
| Закончено |
Spyrosaliv and Cow the Cow are playing a game on a tree of size $$$n$$$.
Spyrosaliv will start at node $$$s$$$. Spyrosaliv and Cow the Cow will play in alternating turns, with Spyrosaliv playing first.
Suppose Spyrosaliv is on node $$$u$$$. Spyrosaliv has to choose any node $$$v$$$ such that the edge $$$(u, v)$$$ exists and is not blocked, and move there. If such a node doesn't exist, he loses. If $$$v = d$$$, he wins.
If it's Cow the Cow's turn, he will do these two operations in the following order:
If both Spyrosaliv and Cow the Cow play optimally, will Spyrosaliv win the game?
The first line contains exactly three integers: $$$n$$$, $$$s$$$, and $$$d$$$ $$$(2 \le n \le 2 \cdot 10^5$$$, $$$1 \le s, d \le n$$$, $$$s \neq d$$$), the size of the tree, Spyrosaliv's starting node, and Spyrosaliv's destination, respectively.
Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$, representing an edge $$$(u, v)$$$ in the tree.
The input is guaranteed to give a valid tree, and it is guaranteed that $$$s \neq d$$$.
Output exactly one string: 'YES' if Spyrosaliv will win and 'NO' otherwise. Note that 'yEs', 'Yes', 'nO', and so on, are also acceptable answers.
5 2 41 42 54 33 5
NO
2 1 21 2
YES
In the first example, the tree is as follows:
Spyrosaliv starts at node $$$2$$$, and wins if he gets to node $$$4$$$. A possible sequence of moves is as follows:
It can be shown that in this example, no matter how Spyrosaliv plays, Cow the Cow has a winning strategy.
| Название |
|---|


