luogu#P4827. [集训队互测 2011] Crash 的文明世界
[集训队互测 2011] Crash 的文明世界
Problem Description
Crash has recently become obsessed with a game called Civilization V. In this game, players can build and develop their own countries, communicate with other countries through diplomacy, or conquer them through war.
Now Crash already owns a country with cities. These cities are connected by roads. Since building roads costs money, Crash only built roads to connect these cities, but it is guaranteed that there is a path between any two cities.
In the game, Crash needs to choose one city as the capital of his country. Choosing the capital requires considering many indicators, and one of them is:
Here, denotes the indicator value of the -th city, is the minimum number of roads that must be traveled from city to city , and is a constant positive integer.
So Crash gives you a simple task: given the roads between the cities, for each city output its indicator value. Since the value may be very large, you only need to output it .
Input Format
The first line contains two positive integers and .
Then there are lines. Each line contains two positive integers (), indicating that there is a road connecting city and city . These roads are guaranteed to satisfy the requirements of the problem.
Output Format
Output lines in total, each with one positive integer. The integer on the -th line represents the indicator value of the -th city .
5 2
1 2
1 3
2 4
2 5
10
7
23
18
18
Hint
For of the testdata, , .
For of the testdata, , .
For of the testdata, , .
Translated by ChatGPT 5