![]() | ||||
Online Judge | Problem Set | Authors | Online Contests | User |
---|---|---|---|---|
Web Board Home Page F.A.Qs Announcement | Current Contest Past Contests Scheduled Contests Award Contest |
The k-th Largest Group
Description Newman
likes playing with cats. He possesses lots of cats in his home. Because
the number of cats is really huge, Newman wants to group some of the
cats. To do that, he first offers a number to each of the cat (1, 2, 3,
¡, n). Then he occasionally combines the group cat i is in and the group cat j is in, thus creating a new group. On top of that, Newman wants to know the size of the k-th biggest group at any time. So, being a friend of Newman, can you help him? Input 1st line: Two numbers N and M (1 ¡Ü N, M ¡Ü 200,000), namely the number of cats and the number of operations. 2nd to (m + 1)-th line: In each line, there is number C specifying the kind of operation Newman wants to do. If C = 0, then there are two numbers i and j (1 ¡Ü i, j ¡Ü n)
following indicating Newman wants to combine the group containing the
two cats (in case these two cats are in the same group, just do
nothing); If C = 1, then there is only one number k (1 ¡Ü k ¡Ü the current number of groups) following indicating Newman wants to know the size of the k-th largest group. Output For every operation ¡°1¡± in the input, output one number per line, specifying the size of the kth largest group. Sample Input Sample Output Hint When there are three numbers 2 and 2 and 1, the 2nd largest number is 2 and the 3rd largest number is 1. Source |
[Submit] [Go Back] [Status] [Discuss]
All Copyright Reserved 2003-2005 Ying Fuchen,Xu Pengcheng
Any problem, Please Contact Administrator