#P16031. [CSPro 33] 词频统计
[CSPro 33] 词频统计
Background
Luogu's testdata is only for non-official communication and use, and is not official testdata. Official judging link: https://www.cspro.org/。
Problem Description
After learning text processing, Little P did some initial organization of articles in an English book. Specifically, Little P converted all English words into integer IDs. Suppose that across these articles, there are distinct words in total, then number them from to . In this way, each article is simplified into an integer sequence, where each number is in the range from to .
Now you are given the articles processed by Little P. For each word (), count:
- In how many articles does word appear?
- How many times does word appear in total across all articles?
Input Format
Read input from standard input.
The input has a total of lines.
The first line contains two positive integers and , representing the number of articles and the upper bound of word IDs.
Line () contains several integers separated by spaces. The first integer is the length (number of words) of the -th article; the next integers give the corresponding integer sequence. Each integer in the sequence is in the range from to , and each corresponds to a word in the original text.
Output Format
Write output to standard output.
Output a total of lines.
On line (), output two integers and separated by a space, meaning that there are articles containing word , and the total number of occurrences is .
4 3
5 1 2 3 2 1
1 1
3 2 2 2
2 3 2
2 3
3 6
2 2
Hint
Sample Explanation
Word appears:
- Twice in article ;
- Three times in article ;
- Once in article .
Therefore, and 。
Subtasks
All testdata satisfies , and each article contains at least one word and at most words ()。
Translated by ChatGPT 5