TASK
3 - Couples
The editor - in - chief of
the weekly magazine Rhodian Matchmaker wishes to
dedicate the next issue to introduce the list of couples that keep their relationship
secret. The only source of information to locate these couples that have not
announced yet their relationship is their common visits at the parties that
take place on the island. The editor-in-chief decided to assign a dedicated
journalist for each couple that appeared at more than K parties to verify their relationship.
Your task is to write a
program that: (a) reads from the input file information about the persons that
were present at each party, (b) calculates the number of journalists the
editor-in-chief will require, and (c) write the result to the output file.
Input
Your program should read
the input from a file "couples.in". The
first line of the file contains three integers N (where 1 ≤
N ≤ 600.000), M (where 1 ≤ M ≤ 20.000), and K (where 3 ≤ K ≤ 1.000), representing the number of
parties, the number of persons and the maximum number of combined appearances
to verify a non-relationship, respectively. That is, for two persons to be
considered as a potential couple, they must appear together at least K +1 times.
The next N lines contain
information about the parties. In particular, each of the next N lines contains one integer X (where 0 ≤ X < N )
standing for the id of the party, one integer Y (where 1 ≤ Y ≤ M ) for the number of persons that were present
at the party and a set of Y numbers
representing the id's of the present persons, ids are in the range [0,M).
Output
Your program should write
the output into a file "couples.out" with 1
line containing a single integer denoting the number of necessary journalists.
Example
couples.in |
couples.out |
Format : In both input and output files, all numbers in
a line are separated with a single space and all lines terminate with a newline character.