luogu#P5058. [ZJOI2004] 嗅探器

    ID: 4065 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2004各省省选浙江Tarjan双连通分量

[ZJOI2004] 嗅探器

Problem Description

In an information warfare exercise, the Red side successfully broke into the Blue side’s internal network.

The Blue side has two information centers. The Red side plans to install a sniffer on some intermediate server so that it can listen to all information exchanged between the two information centers.

However, the Blue side’s network is very large, and packets can travel from one information center to the other through more than one path.

Now you need to solve this problem as quickly as possible: on which intermediate server should the sniffer be installed to ensure that all packets can be captured?

Input Format

The first line contains an integer nn, which is the number of servers in the Blue side’s network.

The next several lines describe the network topology. Each line contains two integers i,ji, j, meaning there is a bidirectional connection between server ii and server jj.

Server IDs start from 11. A line with two 00 indicates the end of the topology description. After that, there are two integers a,ba, b, which are the IDs of the two center servers.

Output Format

Output the ID of a server that satisfies the requirement. If there are multiple solutions, output the one with the smallest ID. If no solution can be found, output No solution.

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

Hint

For 100%100\% of the testdata, 1n2×1051 \le n \le 2 \times 10^5, and the number of edges does not exceed 5×1055 \times 10^5.

Translated by ChatGPT 5