2607. URL

单点时限: 2.0 sec

内存限制: 256 MB

WHU ACM Team is working on a brand new web browser named “Whu-Super-Browser”. You’re in response for a powerful feature: recording the previous addresses. Moreover, when a string is inputted, the browser will display all the addresses start with it. The addresses shall be sorted by visited times, in descending order. This feature is very useful to users.

Can you complete it?

There’re two kinds of operations:

  • Visit [url_str]: visit a website with the URL: [url_str].
  • Display [str]: display all addresses start with [str] and sort them by visited times, in descending order. If two addresses have the same visited times, then sort them in the lexicographical order.

输入格式

The input consists of multiple test cases. The first line of input contains an integer T, which is the number of test cases.

Each test case is on several lines.

The first line of each test case consists of an integer .

Each of the following lines consists of an operation, Visit or Display.

is an integer, and .

is an integer, and .

There’s NO blank line between test cases.

[url_str] and [str] only contains lower case letters a - z, ., /, :.

The length of [url_str] and [str] is greater than and won’t exceed .

输出格式

For each test case, display addresses as required, each address on a separated line.

Add a blank line after each Display operation.

样例

Input
1
10
Visit http://acm.whu.edu.cn
Visit http://acm.pku.edu.cn
Visit http://acm.timus.ru
Visit http://acm.whu.edu.cn
Visit http://acm.whu.edu.cn
Visit http://acm.pku.edu.cn
Display http://acm
Visit baidu.com
Visit www.whu.edu.cn
Display b
Output
http://acm.whu.edu.cn
http://acm.pku.edu.cn
http://acm.timus.ru

baidu.com

112 人解决,171 人已尝试。

154 份提交通过,共有 879 份提交。

4.1 EMB 奖励。

创建: 10 年,10 月前.

修改: 1 年,5 月前.

最后提交: 1 周,3 天前.

来源: The 4th Baidu Cup Central China Invitational Programming Contest

题目标签