/ GCOJ / 题库 /

[GCOI Round #1 E] Network

[GCOI Round #1 E] Network

题目描述

Mr Aoligei became the boss of the network company. There are \(n\) houses (including the company) in his network, N-1 bidirectional channels to connect the nodes, and there always exists a route from any house to another house. Each channel is 1 kilometer long. The company is house \(h\) and the money a house needs to pay is the distance of the route between the company and the house.

Now, Mr Poo lives in house \(t\). He wants to know how much money does he need to pay.

输入格式

The first line of the input file contains two integers: \(n, t, h\).

Following N-1 lines represent the channels in the original network of SN, each pair \((a, b)\) denote that there is a channel between node a and node b.

输出格式

Print out the money he needs to pay.

输入输出样例

Input #1:

5 4 3
3 1
3 4
3 2
4 5

Output #1:

1

信息

ID
1008
难度
4
分类
搜索 | 数据结构 | 树结构 | 最近公共祖先 点击显示
标签
递交数
4
已通过
1
通过率
25%
上传者

相关

在下列比赛中:

GCOI Round #1