#C8859. Social Network Log Processor
Social Network Log Processor
Social Network Log Processor
In this problem, you are given a social network with users and a log containing actions. There are three types of actions:
- Type 1 action:
1 u m
— User posts a message with identifier . - Type 2 action:
2 u v m
— User forwards a message with identifier to user . - Type 3 action:
3 u
— Retrieve all messages received by user (in chronological order).
For every type 3 action, output a single line containing all message identifiers for the queried user separated by a single space. If the user has not received any messages, output an empty line.
Note: All numerical values and message identifiers in the input are separated by spaces.
inputFormat
The first line contains two integers and , where is the number of users and is the number of actions. Each of the following lines contains an action in one of the following formats:
1 u m
: User $u$ posts a message with identifier $m$.2 u v m
: User $u$ forwards a message with identifier $m$ to user $v$.3 u
: Retrieve and output all messages received by user $u$ in the order they were received.
outputFormat
For each type 3 action in the input, print a line containing the message identifiers for the requested user separated by a single space. If a user has no messages, print an empty line.## sample
5 7
1 1 101
1 2 102
2 1 3 103
1 3 104
3 3
2 2 1 105
3 1
103 104
101 105
</p>