Dance Team Pairing Challenge
Imagine you are helping Ninja, a dance coach, who needs to form dance pairs from the available boys and girls in a studio. Given the number of boys N
, the number of girls M
, and the possible pairings, determine the maximum number of dance pairs possible. Help him by determining the best arrangement of these pairs.
Input:
The input begins with an integer 'T' denoting the number of test cases.
For each test case, the first line contains three space-separated integers: N
, M
, and K
representing the count of boys, girls, and potential pairings.
The following K
lines contain space-separated integers 'a' and 'b', where 'a' is the index of a boy and 'b' is the index of a girl who can potentially be paired.
Output:
For each test case, output '1' if a set of the maximum possible pairs is returned. Otherwise, output '0'. Each result should be printed on its own line.
Example:
Input:
2
2 2 2
1 1
2 2
3 3 3
1 2
2 3
3 1
Output:
1
1
Constraints:
1 ≤ T ≤ 5
1 ≤ N ≤ 100
1 ≤ M ≤ 100
1 ≤ K ≤ 100
1 ≤ a ≤ N
1 ≤ b ≤ M
Note: There might be multiple sets of valid pairings; in such cases, you can return any valid configuration of pairs.
Be the first one to answer
Add answer anonymously...
Top Tower Research Capital LLC Software Engineer interview questions & answers
Popular interview questions of Software Engineer
>
Tower Research Capital LLC Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app