#K80362. Manage Names
Manage Names
Manage Names
You are given a series of commands to manage a list of names. Each command is either add name
or remove name
. The add name
command adds the specified name into the list (if it is not already present), while the remove name
command removes the name if it exists in the list.
After processing all commands, you are required to output the final list of names in ascending order. The rules for the operations can be summarized as follows:
- \(\text{add: insert the name if not present}\)
- \(\text{remove: delete the name if it exists}\)
Note that the names are case-sensitive and are given in lower-case only.
inputFormat
The input begins with a single integer \(N\) (\(0 \leq N \leq 1000\)) representing the number of commands. Each of the following \(N\) lines contains one command in the form of either add name
or remove name
.
outputFormat
Output the final sorted list of names, each on a new line. If no names remain after processing all commands, output nothing.
## sample6
add alice
add bob
add charlie
remove bob
add dave
remove bob
alice
charlie
dave
</p>