Submit solution
Points:
12 (partial)
Time limit:
2.0s
Memory limit:
64M
PyPy 2
128M
PyPy 3
128M
Author:
Problem types
You have a graph of nodes and queries.
Queries will be in two types:
1 x y
: Add an edge between nodes and ).
2 k
: Print the sum of the sizes of the connected components whose sizes are less than or equal to .
Input Specification
The first line will contain two integers and .
The next lines will contain a query of one of the two types described above.
Output Specification
You are to print one line for each type 2
query: the sum described in the problem statement.
Subtasks
Subtask 1 (30%)
Subtask 2 (70%)
No further constraints.
Sample Input
5 5
1 1 2
2 1
1 2 3
1 4 5
2 2
Sample Output
3
2
Comments