#C7101. Adjust Friend Visibility
Adjust Friend Visibility
Adjust Friend Visibility
You are given a list of friend names and a sequence of operations. Each operation is one of the following:
- block x — Add friend
x
to the blocklist. Ifx
is already blocked, no changes are made. - unblock x — Remove friend
x
from the blocklist. Ifx
is not blocked, no changes are made. - list — Print the names of all unblocked friends in lexicographical order, separated by a single space. If no friends are visible, print an empty line.
Process the operations in the given order and output a result for every list command.
inputFormat
The input is read from standard input with the following format:
The first line contains an integer n representing the number of friends. The second line contains n space-separated friend names. The third line contains an integer m representing the number of operations. The following m lines each contain an operation in one of the three formats: "block x", "unblock x", or "list".
It is guaranteed that there is at least one "list" operation.
outputFormat
For each "list" operation, output a single line containing the lexicographically sorted list of unblocked friend names, separated by a single space. If no friends are visible at that moment, output an empty line.## sample
5
alice bob charlie dave eve
6
block alice
list
block bob
list
unblock alice
list
bob charlie dave eve
charlie dave eve
alice charlie dave eve
</p>