#P15494. [ICPC 2025 APC] Cactus Connectivity
[ICPC 2025 APC] Cactus Connectivity
Description
You are interested in the topic of graphs and their properties. In this problem, we assume that all graphs are simple undirected graphs, meaning there is at most one edge connecting any pair of vertices and each edge connects different vertices.
A simple cycle of a graph is a sequence of three or more distinct vertices such that there exists an edge connecting vertices and for each and there also exists an edge connecting vertices and . For a simple cycle , its edge set is defined as $\{(v_1, v_2), (v_2, v_3), \ldots, (v_{c-1}, v_c), (v_c, v_1)\}$, where represents an edge connecting vertices and . Two simple cycles are the same if they share the same edge set.
A graph is a cactus if any two distinct simple cycles share at most one common vertex. For example, Figure C.1 illustrates three graphs. Graph is a cactus since the two simple cycles and only share vertex as the common vertex. Note that the sequence of vertices does not form a simple cycle since vertex appears twice. Also, the simple cycle is the same simple cycle as the simple cycle . Meanwhile, graph is not a cactus since the two simple cycles and share vertices and as the common vertices. Graph is a cactus since there is only one simple cycle.
:::align{center}

Figure C.1: Graphs and are cactii. Graph is not a cactus. :::
A graph is connected if there is a path connecting every pair of vertices. In particular, a graph with one vertex is connected.
For any positive integer , a graph is -edge-connected if, for any set of fewer than edges, removing those edges leaves the graph connected. In particular, all connected graphs are -edge-connected. For example, graph in Figure C.1 is -edge-connected and -edge-connected, but not -edge-connected, since removing both edges incident to vertex does not leave the graph connected.
A graph is a supergraph of a graph if can be obtained by adding zero or more vertices and edges to without removing any vertices and edges from . Note that two graphs are the same if they have the same set of vertices and the same set of edges. For example, in Figure C.1 above, graph is a supergraph of graph , while graph is not a supergraph of graph since it is missing the edge connecting vertices and .
The connectivity value of a graph is the smallest positive integer such that, for any -edge-connected graph that is a supergraph of , removing all the edges of from keeps connected. For example, in Figure C.1 above, graph is a -edge-connected supergraph of graph , and removing all the edges of from leaves vertices and disconnected from the rest, as illustrated by Figure C.2 below. Therefore, the connectivity value of is more than . It can be shown that the connectivity value of is .
:::align{center}

Figure C.2: Removing the edges of graph from graph :::
You are given a cactus with vertices and edges, where the vertices are numbered from to and the edges are to . Edge connects vertices and . You are required to compute the connectivity value of the cactus.
Input Format
The first line of input contains two integers and (; ). The -th of the next lines contains two integers and (). The input represents a cactus with at most one edge connecting any pair of vertices.
Output Format
Output the connectivity value of the given graph.
4 3
1 2
2 3
1 3
3
3 0
1
Hint
Explanation for the sample input/output #1
This corresponds to graph from the problem description.
Explanation for the sample input/output #2
Any -edge-connected supergraph is a connected graph. Since the given graph has no edges, removing all the edges of the given graph from a connected graph keeps the graph connected.
京公网安备 11011102002149号