#C9407. Unique Message Count
Unique Message Count
Unique Message Count
You are given a log file containing records in the following format: each record is a line comprising two integers and a message string. The two integers represent the sender ID and the receiver ID, and the message string (which may contain spaces) is the content of the message. Your task is to count the number of unique messages sent by each sender. Two messages are considered the same if their content is exactly the same.
For each sender that appears in the log, output a line with the sender's ID and the number of unique messages sent, in increasing order of the sender's ID.
Mathematically, if S is the set of sender IDs and M(s) is the multiset of messages sent by sender s, then you need to compute for each s in S: [ \text{uniqueCount}(s) = \left|{ m : m \in M(s) }\right| ]
If there are no log entries, print nothing.
inputFormat
The first line of input contains an integer (n) ( (0 \le n \le 10^5)) representing the number of log entries. Each of the following (n) lines contains a log entry in the format:
sender_id receiver_id message
Here, (sender_id) and (receiver_id) are integers, and (message) is a string that may contain spaces. Note that the message spans from the third word to the end of the line.
outputFormat
For each sender that appears in the logs, output a line in the following format:
sender_id unique_message_count
The senders must be listed in increasing order of sender_id. If (n = 0), the output should be empty.## sample
7
1 2 Hello
2 3 Hi
1 2 Hello
1 3 Good morning
2 1 Hi
3 1 Hey
1 2 What's up?
1 3
2 1
3 1
</p>