#K92742. Find Tagged Users
Find Tagged Users
Find Tagged Users
You are given a list of messages. Each message is associated with a sender, a recipient, and a content string. The content might include several user tags, each denoted by an "@" symbol immediately followed by one or more digits (for example, @123). Your task is to extract all such tags from every message, convert them into integers (ignoring any leading zeros) and output a sorted list of unique user IDs.
The input is provided via standard input and the answer must be printed to standard output.
Note: Tags may appear multiple times in a message or across messages. If no tag is found, output an empty line.
inputFormat
The input begins with a single integer n on the first line, representing the number of messages. The following n lines each contain a message in the format: sender recipient content
.
The sender
and recipient
are positive integers, and content
is a string (which may contain spaces) that can include tags in the format @number
(e.g. @3, @03, etc.).
outputFormat
Output a sorted sequence of unique user IDs (integers) that have been tagged in any of the messages. Print them in one line separated by a single space. If no tag is found, output an empty line.
## sample5
1 2 Hello @3, how are you?
2 3 Hey @1, check this out @4.
3 1 @2 can you review this?
4 2 Thank you, @3!
2 2 Meeting @4 and @1 today.
1 2 3 4