#K46907. Unique Bookmark Tracker

    ID: 28080 Type: Default 1000ms 256MiB

Unique Bookmark Tracker

Unique Bookmark Tracker

You are given a sequence of instructions regarding bookmarks in various books. Each instruction is provided in one of the following formats:

  • Bookmark Logging: "page_number book_name bookmark_design" (for example, "12 harrypotter griffin"). This instruction adds the bookmark_design to a global set of bookmarks.
  • Check Command: "0". When this command appears, you must output the current list of unique bookmark designs sorted in lexicographical (alphabetical) order, separated by a single space. If no bookmarks have been logged so far, output "None".

The bookmarks accumulate over the entire input; that is, once a bookmark is added, it remains for all subsequent check commands.

Note: All output should exactly match the required format.

inputFormat

The input is given via standard input (stdin) as multiple lines. Each line represents a single instruction. The instruction is either in the format "page_number book_name bookmark_design" (to log a bookmark) or "0" (to perform a check and output the sorted list of bookmarks).

outputFormat

For each line in the input that is a check command (i.e. "0"), output a single line to standard output (stdout):

  • If at least one bookmark has been logged so far, output the unique bookmark designs in lexicographical order, separated by a single space.
  • If no bookmark has been logged so far, output the string "None".
## sample
12 harrypotter griffin
25 lotr dragon
40 hobbit sword
0
19 harrypotter phoenix
0
30 dracula bat
0
dragon griffin sword

dragon griffin phoenix sword bat dragon griffin phoenix sword

</p>