Files
PAT/html/a1107.html
T

33 lines
1.4 KiB
HTML

<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<h1>1107. Social Clusters (30)</h1>
<div id="problemContent">
<p>When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. A "social cluster" is a set of people who have some of their hobbies in common. You are supposed to find all the clusters.</p>
<p><b>
Input Specification:
</b></p>
<p>Each input file contains one test case. For each test case, the first line contains a positive integer N (&lt;=1000), the total number of people in a social network. Hence the people are numbered from 1 to N. Then N lines follow, each gives the hobby list of a person in the format:</p>
<p>
K<sub>i</sub>: h<sub>i</sub>[1] h<sub>i</sub>[2] ... h<sub>i</sub>[K<sub>i</sub>]</p>
<p>where K<sub>i</sub> (&gt;0) is the number of hobbies, and h<sub>i</sub>[j] is the index of the j-th hobby, which is an integer in [1, 1000].</p>
<p><b>
Output Specification:
</b></p>
<p>For each case, print in one line the total number of clusters in the network. Then in the second line, print the numbers of people in the clusters in non-increasing order. The numbers must be separated by exactly one space, and there must be no extra space at the end of the line.
</p>
<b>Sample Input:</b><pre>
8
3: 2 7 10
1: 4
2: 5 3
1: 4
1: 3
1: 4
4: 6 8 1 5
1: 4
</pre>
<b>Sample Output:</b><pre>
3
4 3 1
</pre>
</div>