#P5489. EntropyIncreaser 与 动态图
EntropyIncreaser 与 动态图
Background
It is said that when NaCly_Fish was having a meal with , he asked her a question: “Given an undirected graph that supports dynamic edge insertions, how do we find the number of articulation points between two vertices?”
thought for a few seconds and said: “Isn’t this a super easy problem? You can do it however you want.” Then she explained an algorithm in just a few sentences.
But NaCly_Fish still did not understand it. Please teach her how to solve this problem.
Problem Description
There is a graph with vertices, initially with no edges.
There are operations, of types, as follows:
1 u vmeans adding an undirected edge between and .2 u vmeans querying the number of bridges between and .3 u vmeans querying the number of articulation points between and .
In particular, for operations and , if and are not connected, output .
To avoid ambiguity, here are the definitions of the number of bridges and articulation points between two vertices:
Let be the intersection of the vertex sets of all paths that contain both and . Define the number of elements in as the number of articulation points between and .
Let be the intersection of the edge sets of all paths that contain both and . Define the number of elements in as the number of bridges between and .
This problem is strictly online.
Starting from the second line, in each input, must be XORed with to get the actual .
is the answer of the most recent query whose answer is not , and initially .
ps: If you do not know what XOR means, see here: xor.
Input Format
The first line contains two positive integers , representing the number of vertices and the number of operations.
The next lines each contain three integers, describing one operation.
Output Format
For each operation of type or , output one line with one integer representing the answer.
5 10
1 1 2
1 2 3
2 1 3
3 0 1
1 3 1
1 1 6
2 3 7
1 6 7
1 7 1
3 3 6
2
2
-1
3
Hint
The background story is a real event.
Sample Explanation
The actual operations are:
5 10
1 1 2
1 2 3
2 1 3
3 2 3
1 1 3
1 3 4
2 1 5
1 4 5
1 5 3
3 1 4
Constraints
For of the testdata, .
For another of the testdata, all operations of type and occur after a type operation.
For of the testdata, , .
For type operations, it is guaranteed that .
By: NaCly_Fish
Welcome to join the EI Captain fan group. Group number: .
Translated by ChatGPT 5