Villain Con
Submissions: 1549   Accuracy:


  Difficulty: Easy   Marks: 2

The minions are very elitist in nature.
If minion x admires minion y, then y thinks too high of himself and does not admire x
Also, if x admires y, x also admires everyone that y admires. All minions are going
to be present at the “Villain Con”.
The minions wanted to make sure that they do not
wear dress of same color as someone who admires them.
Given who admires whom Gru (Minion’s Master) thought of finding the minimum
number of different colored dresses that minions will be seen.



1st Line Contains T number of test cases
The next line contains the number of minions (N) and the number of relations the
minions will have (M).
Next M lines will contain Xi and Yi separated with space
i.e. Yi admires Xi


Minimum no. Of different colored dresses


T ≤ 10

0 ≤ N ≤ 100000

1 ≤ M ≤ 2*100000

1<= Xi,Yi <= N



5 6
1 3
2 3
3 4
1 4
2 5
3 5




1, 3, and 5 cannot wear the same dress. so the count is 3

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Jai Goyal
Author: goyal_banna

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.