Write a program to pick the clubs that have no member in common.
Task Description
There are N clubs for 64 persons to join. Each person has an id from 0 to 63. Each person can join as many clubs as he wishes. After people join the clubs, you need to pick K clubs so that no two clubs have any person in common. That is, the member list of any two chosen clubs are disjoint. For example, if we have five clubs A, B, C, D and E. The following are the member list for each club:
club id
club name
member list
0
club A
6, 7, 9
1
club B
11, 13, 17
2
club C
6, 13, 15
3
club D
0, 4, 5, 8, 33, 63
4
club E
10
The members of club A and club B are disjoint since they do not have any common member. However, the members of club A and club C are not disjoint since they have common member 6. Thus, we have four clubs A, B, D, E whose members are disjoint.
Note that we need to choose K clubs in alphabetic (dictionary) order if there are more than one solutions. For example, if K = 4, obviously we have only one solution (A, B, D, E). If K = 3, we have four solutions (A, B, D), (A, B, E), (A, D, E), (B, D, E) and we will choose the solution (A, B, D) since it has the least alphabetic order.
Write a program to pick out K clubs that have no member in common, and output K clubs with their id which is from 0 to N-1. It is guaranteed that there exists a solution.
Subtask
20 points: K = 2.
40 points: K > 2.
40 points: N and K are very large and you will get TLE if you do not use bit operations. Note that it is very straightforward to represent a set of people as a long long unsigned integer. Then it is also straightforward to efficiently check whether two sets of people are disjoint using bit operations. Also you need to solve this problem recursively. You need to determine whether you should pick a club. What parameters should be changed for the recursion if you do choose this club, and what parameters should be changed if you do not choose this club?
Input Format
The input contains only one test case. The first line contains two integers N and K, where N is the number of the clubs, and K is the number of disjoint clubs we will pick. The rest of input are the member information for each club. Each line contains a sequence of integers. The first integer M in each line is the number of members, and it is followed by the member list of the club. It is guarantee that there is at least one member for each club.
N < 101
1 < K <= N
M < 65
Output Format
Print ids of K clubs which have no member in common. Note that the id number should be print in increasing order.
Write a program to pick the clubs that have no member in common.
Task Description
There are N clubs for 64 persons to join. Each person has an id from 0 to 63. Each person can join as many clubs as he wishes. After people join the clubs, you need to pick K clubs so that no two clubs have any person in common. That is, the member list of any two chosen clubs are disjoint. For example, if we have five clubs A, B, C, D and E. The following are the member list for each club:
The members of club A and club B are disjoint since they do not have any common member. However, the members of club A and club C are not disjoint since they have common member 6. Thus, we have four clubs A, B, D, E whose members are disjoint.
Note that we need to choose K clubs in alphabetic (dictionary) order if there are more than one solutions. For example, if K = 4, obviously we have only one solution (A, B, D, E). If K = 3, we have four solutions (A, B, D), (A, B, E), (A, D, E), (B, D, E) and we will choose the solution (A, B, D) since it has the least alphabetic order.
Write a program to pick out K clubs that have no member in common, and output K clubs with their id which is from 0 to N-1. It is guaranteed that there exists a solution.
Subtask
Input Format
The input contains only one test case. The first line contains two integers N and K, where N is the number of the clubs, and K is the number of disjoint clubs we will pick. The rest of input are the member information for each club. Each line contains a sequence of integers. The first integer M in each line is the number of members, and it is followed by the member list of the club. It is guarantee that there is at least one member for each club.
Output Format
Print ids of K clubs which have no member in common. Note that the id number should be print in increasing order.
Sample Input 1
Sample Output 1
Sample Input 2
Sample Output 2
Sample Input 3
Sample Output 3