#C3752. Minimum Roads to Block
Minimum Roads to Block
Minimum Roads to Block
You are given a tree of n towns (nodes) connected by exactly n-1 roads (edges). In a tree, any single road removal will disconnect the graph into two separate parts. Your task is to determine the minimum number of roads that must be blocked in order to disconnect the kingdom.
Note: It is guaranteed that the input graph is a tree and n ≥ 2. Therefore, the answer is always 1.
For example, consider the following test case:
Input: 4 1 2 1 3 2 4</p>Output: 1
inputFormat
The input is read from standard input and has the following format:
- The first line contains an integer
n
(n ≥ 2
), the number of towns. - The following
n-1
lines each contain two integersu
andv
, indicating a road connecting townu
with townv
.
outputFormat
Output a single integer on a new line to standard output: the minimum number of roads to block in order to disconnect the kingdom.
## sample4
1 2
1 3
2 4
1