BAD - Badminton Tournament - Easy
In a badminton tournament, each of n players play all the other n - 1 players. Each game results in either a win, or a loss. Players then write down the names of those whom they defeated(say list 1) and also of those who they(players of list 1) defeated. For example, if A beats B and B beats C, then A writes the names of both B and C.
Consider a game between A, B, C, D, E, F, G where A defeats B, C; B defeats E; C defeats F. Then A's list will have (B, C, E, F) and will not include G.
Note: Say A defeats B, B defeats C and C defeats D. D is not necessarily present in A's list, a player's list contains players of list1 and players defeated by those in list1(immediate win).
In this problem, we represent players by integers from 1 to n.(Both inclusive)
First line of input contains an integer t(number of test cases), each test case starts with an integer n followed by nc2(i.e n*(n - 1)/2) lines(results of all matches) each containing two integers a, b seperated by a space which means a defeated b.
Print a line for each test case containing two space seperated integers p, q where p is the player with maximum possible number of players in his list and q is that number(maximum possible number of players in a list).
In case there are many players with maximum number of players in their list, print minimum of such possibilities of p.
t <= 50, n <= 250, 1 <= a, b <= n
My best: 0.53s with PyPy and 1.50s with Python 2.7.9. Good Luck! :)
Easy problem , brute force works.........
don't try the toolkit..that's wrong..
what the hell. in__buitin_popcount does not work for long long int.
I did not understand what you mean to say in note. D is not necessarily included in A's list. So, i want to know in which case we will include D , and in which case, we will exclude D.
Awesome problem!! AC in one go for .3 points :D
can you give us more test cases? :)
A beats B, B beats C, C beats A..