#P1735. Tree

Tree

题目描述

Toilet-Ares and Unidentified-person are playing a game on a tree with n vertices. A tree is a connected undirected graph with no cycles. The vertices are numbered from 1 to n. Initially, Toilet-Ares is at vertex number ss, and Unidentified-person is at vertex number tt.

They move in turns, and Toilet-Ares moves first. Upon every move, the player must select one neighbor of his/her own vertex and goes there. After going to the new vertex, the player then removes the old vertex and all edges connected to it. The player must move whenever possible, and the game ends when both players cannot move. Each player's score equals the number of moves he/she made.

Both Toilet-Ares and Unidentified-person are trying to maximize his/her own score minus the other player's score. Assuming they are extremely smart and always select the best move possible, what is Toilet-Ares's score minus Unidentified-person's score when the game ends?

输入格式

The first line contains three integers tn,s,ttn, s, t $(1\\le n\\le 5\ imes 10^5, 1\\le s, t,\\le n, s\ eq t)$.

Each line of the next n1n - 1 lines contains two integers u,vu,v (1lequ,vleqn)(1 \\leq u, v \\leq n), denoting an edge between uu and vv.

输出格式

One line contains one integer, denoting the answer.

样例

5 1 4 
1 2 
1 3 
3 4 
4 5
0

提示

来自:2021牛客暑期多校训练营8

搬运by FrankOu