Count the equal two-team splits in which every pair across the teams played at least once, and print the lexicographically smallest team containing player 1.
Medium7GraphUnion-findDynamic programmingNo attempts yetTime limit3sMemory limit256 MBA big chess tournament is being held in your town, so you go and watch. Two teams A and B, each with n players, face each other, and every player of team A plays one game against every player of team B. The team with more wins takes the title. In a drawn game each player gets 1/2 point.
You do not know which players are on which team, but you wrote down every game played during the tournament. The catch is that some players also played outside the schedule, for practice or for fun. Some of those games were against a teammate, some against an opponent they had already faced. Can you still tell who belongs to which team?
Count the team assignments that agree with your list, that is, the assignments in which every pair of players from opposite teams appears in the list at least once. The two teams have no names, so swapping A and B gives the same assignment.
The first line has the number of test cases T (1≤T≤100). Each test case is given as follows.
The same pair may appear more than once. The sum of M over all test cases is at most 106. Players are numbered 1 through 2N, and at least one assignment that agrees with the list always exists.
For each test case print two lines.