#P12014. [Ynoi April Fool's Round 2025] 牢帽
[Ynoi April Fool's Round 2025] 牢帽
Background





Problem Description
Hoshino Kana gives you an undirected graph with vertices. The graph initially has no edges. She also gives you integers and . There are operations of four types:
1 x y: Add an edge between and . It is guaranteed that this edge does not exist before.2 x y: Delete the edge between and . It is guaranteed that this edge exists before.3 x y: Modify to .4 x: Suppose the graph is divided into connected components . Compute .
Input Format
The first line contains four integers .
The second line contains integers .
The next lines each describe one operation.
Output Format
Output several lines. Each line contains one integer, the answer for each type operation.
5 10 3 2
1 2 3 4 5
4 2
1 1 2
1 3 4
4 0
1 2 3
3 2 5
4 1
2 3 4
1 4 5
4 2
7
1
3
3
Hint
Idea: I forgot the source. Please ask the original problem setter by private message on QQ.
Sample 2
See the attachments ex_c2.in and ex_c2.ans. This sample satisfies Subtask .
Sample 3
See the attachments ex_c3.in and ex_c3.ans. This sample satisfies Subtask .
Sample 4
See the attachments ex_c4.in and ex_c4.ans. This sample satisfies Subtask .
Limits and Notes
This problem uses bundled tests.
For of the data, , , , . In type operations, , and in type operations, , are both non-negative integers less than .
| Subtask ID | Score | Special Property | ||
|---|---|---|---|---|
| For all type operations, . | ||||
| . | ||||
| For all type operations, is a multiple of . | ||||
| There are no type or type operations. | ||||
Translated by ChatGPT 5