#P4625. [SHOI2009] 巴士路线

    ID: 3569 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>2009各省省选上海Special Judge

[SHOI2009] 巴士路线

Description

There are nn small villages around OItown. There are roads between villages, and each road connects two villages. Because these villages are not wealthy, when the roads were built, they were built just enough to make all villages connected. That is, for any two villages, there is a unique way to walk from one to the other along the roads. Therefore, sometimes two villages that are very close still require a long walk along the roads. So the villagers hope to open public transport routes on these roads to make travel more convenient.

The bus operating company accepted this suggestion. At the same time, the company requires that the bus routes must satisfy the following conditions:

  1. The start and end points of each bus route are in villages, and the bus runs along the roads.
  2. Every road must be covered by some bus route, so that villagers only need to switch to taking buses.
  3. Each road is covered by exactly one bus route, and is covered only once. Otherwise, the company thinks it is not cost-effective.
  4. The total number of bus routes should be as small as possible, to make management easier.

For example, if the 55 roads among 66 villages are like this:

Then the following 33 bus routes can satisfy the conditions above: 1231-2-3, 242-4, 5465-4-6.

However, the residents naturally think that “bus transfers” are inconvenient, so they hope that the maximum number of transfers needed when traveling from one village to another is as small as possible. For example, in the route arrangement above, going from village 11 to village 66 requires 22 transfers, which is the maximum number of transfers.

On the other hand, the bus company believes that a longer bus route means that if a bus breaks down, more passengers will be affected and delayed. Therefore, the company hopes that the longest route is as short as possible. “Short” means it passes through fewer villages.

Now the task of designing the bus routes is given to you, a contestant of SHTSC. You must consider both factors above, so you need to compute: (1) the minimum possible value of the maximum number of transfers. (2) the minimum possible value of the number of villages passed through by the longest route.

Input Format

The first line of the input contains an integer nn, the number of villages.

Each of the following lines contains two integers xx and yy, describing a road, meaning there is a road between villages xx and yy.

The input guarantees that each road is described only once.

Output Format

The output has three lines:

The first line contains an integer, the number of routes in the bus route arrangement.

The second line contains an integer, the minimum possible value of the maximum number of transfers.

The third line contains an integer, the minimum possible value of the number of villages passed through by the longest route.

6
1 2
2 3
4 5
5 6
2 5
3
2
3
12
1 2
2 3
3 4
4 5
5 6
6 7
2 8
3 9
4 10
5 11
6 12
6
2
3

Hint

If the first line of your output is the same as the standard answer, you can get 22 points.

If the second line of your output is the same as the standard answer, you can get 44 points.

If the third line of your output is the same as the standard answer, you can get 44 points.

Constraints:

For 70%70\% of the testdata: n300n \le 300. For 100%100\% of the testdata: n105n \le 10^5.

Translated by ChatGPT 5