All submissions for this problem are available.
Our very own Felicity(Overwatch) suddenly got an urgent work to analyse the most active groups of Villains. So, she left the onus of saving the world on the other superheroes and is now toiling hard to find a way to the task.
She has 2N villains with 1 to N in set V and N+1 to 2N in set W both inclusive. Working with superheroes has taken a toll on her mind and now she only understands things in terms of computing and villains.
So, she decided to make a cluster of villains who work together. Here (V1,W1),(V2,W2),...,(Vn,Wn) represents the connection between the villains.
Now, she wants to print the no. of villains in the smallest and the largest groups.
Note: A villain working alone should not be considered in the answer.
InputFirst line contains an integer N.
Each of the next lines contain two space-separated integers, line contains Vi and Wj.
Print two space separated integers, the number of villains in the smallest and the largest groups.
- 1 ≤ N ≤ 15000
- 1 ≤ Vi ≤ N
- N+1 ≤ Wi ≤ 2N
Input: 5 1 6 2 7 3 8 4 9 2 6
Output: 2 4
ExplanationThe number of villains in the smallest connected group is containing 2 i.e. either (3,8) or (4,9). The number of villains in the largest connected group is containing 4 (1,2),(2,6) and (6,7).
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, CS2, PAS fpc, PAS gpc, GO, NODEJS, HASK, D, PERL, FORT, ADA, CAML, ICK, BF, ASM, CLPS, ICON, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, JS, ERL, kotlin, PERL6, CLOJ, COB, FS|
Fetching successful submissions