ZOJ Problem Set - 3309
In order to celebrate the 8th anniversary of ZOJ, ZJU ACM team members are watering in the forum. In the forum, there's a function named "search new posts". You are shown a list of posts that are updated recently. When a post is new, or a post is replied, the post tops the list. So when you do the "search" operation, the list of newly updated posts will be shown, top of which is the newest. You can also tag some of the posts as "read", so they will not appear in the list until they are replied again later. Supposed you should only print at most the top 100 posts of the lists (that means, if the list contains more than 100 posts, you should only output the top 100 ones).
Now, you are given a list of operations, and you are asked to list the new posts after each "search" operation. The operations include:
It's guaranteed that all operations are legal. All posts will be operated "new" just once. It's guaranteed that all posts operated "reply" and "tag" exist. A post can be tagged as "read" more than once before it is replied. Each postname contains one word, with no spaces in the word. The length of the postwords may be as long as 50. There will be no more than 10000 postnames.
There are multiple cases. In each case, the first line is an integer N (2 < N < 100000), indicating the number of operations. In the following N lines, each line contains one operation shown as mentioned above. The number of operations in the input will be less than 200000 IN TOTAL.
In each case, print the new posts list for each "search" operation. One line for each post. Print a line "###" after each list. Print an empty line after each case.
8 new Michael_Jackson new Holiday search reply Michael_Jackson search new Anyone_BG tag Holiday search
Holiday Michael_Jackson ### Michael_Jackson Holiday ### Anyone_BG Michael_Jackson ###
Author: SHE, Jieying
Source: ZOJ 8th Anniversary Contest