The population of HackerWorld is . Initially, none of the people are friends with each other. In order to start a friendship, two persons and have to shake hands, where . The friendship relation is transitive, that is if and shake hands with each other, and friends of become friends with and friends of .
You will be given queries. After each query, you need to report the size of the largest friend circle (the largest group of friends) formed after considering that query.
For example, your list of queries is:
First, and shake hands, forming a circle of . Next, and do the same. Now there are two groups of friends. When and become friends in the next query, both groups of friends are added together to make a circle of friends. We would print
Complete the function maxCircle in the editor below. It must return an array of integers representing the size of the maximum circle of friends after each query.
maxCircle has the following parameter(s):
queries: an array of integer arrays, each with two elements indicating a new friendship
The first line contains an integer, , the number of queries to process.
Each of the next lines consists of two space-separated integers denoting the 2-D array .
Return an integer array of size , whose value at index is the size of largest group present after processing the query.
Sample Input 0
21 21 3
Sample Output 0
In the first query, and shake hands. So, the size of largest group of friends is (as no other friendships exist).
After the second query, , and all become friends, as shakes hand with , also become friends with as he was already a friend of .
Sample Input 1
41000000000 2311 37787 4711 1000000000
Sample Output 1
After first query, person and person become friends. So, the largest group size is .
After the second query, person and person become friends. So, the largest group size is still .
After the third query, person and person become friends. Answer is still .
After the last query, person and person become friends, which means , , and all become friends. Hence, the answer now increased to .