#P8954. 「VUSC」Math Game
「VUSC」Math Game
Background
upd 2023.1.22: Added one set of hack testdata by
Bessie, far away in Moo-lica, also wants to visit friends and relatives during the Spring Festival. To kill time, she often plays an interesting number game with Farmer John.
Problem Description
Farmer John has a set , initially .
For two positive integers in the set , we call them "a pair of good numbers" if and only if .
We treat each number in as a node in an undirected graph. For each pair of "good numbers", we add an undirected edge between these two numbers.
Farmer John will perform operations of the following two types:
- Given , ask for the size of the connected component containing node .
- Given , remove from . At the same time, node in the undirected graph is also removed.
Since Bessie is too slow, she wants you to help.
Input Format
The first line contains two positive integers .
The next lines each contain two positive integers . Here, denotes the type of the operation.
It is guaranteed that is in the set .
Output Format
For each operation of type , output one positive integer per line, which is the answer to the query.
30 6
1 6
1 4
2 9
1 3
2 2
1 16
1
4
2
2
Hint
Sample Explanation
This is the original undirected graph (all nodes in the top row are isolated nodes):

This is the undirected graph after the first type operation (node is deleted):

This is the undirected graph after the second type operation (node is deleted):

Constraints
All testdata satisfy:
Test points additionally satisfy , .
Test points additionally satisfy that all , where is a constant satisfying .
Test points have no additional constraints.
Translated by ChatGPT 5