描述

WHUACMTeamisworkingonabrandnewwebbrowsernamed"Whu-Super-Browser".You'reinresponsefora powerfulfeature:recordingthepreviousaddresses.Moreover,whenastringisinputted,thebrowserwilldisplayallthe addressesstartwithit.Theaddressesshallbesortedbyvisitedtimes,indescendingorder.Thisfeatureisveryusefulto users. Canyoucompleteit?
There'retwokindsofoperations:
Visit[url_str]:visitawebsitewiththeURL:[url_str].
Display[str]:displayalladdressesstartwith[str]andsortthembyvisitedtimes,indescendingorder.Iftwoaddresses
havethesamevisitedtimes,thensorttheminthelexicographicalorder.

输入

Theinputconsistsofmultipletestcases.ThefirstlineofinputcontainsanintegerT,whichisthenumberoftestcases.
Eachtestcaseisonseverallines. ThefirstlineofeachtestcaseconsistsofanintegerN. EachofthefollowingNlinesconsistsofanoperation,VisitorDisplay.

[TechnicalSpecification]
Tisaninteger,andT<=10.
Nisaninteger,and1<=N<=100.
There'sNOblanklinebetweentestcases.
[url_str]and[str]onlycontainslowercaseletters'a'-'z','.','/',':'.
Thelengthof[url_str]and[str]isgreaterthan0andwon'texceed100.

输出

For each test case, display addresses as required, each address on a separated line. Add a blank line after each 'Display' operation.

样例输入

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

样例输出

http://acm.whu.edu.cn
http://acm.pku.edu.cn
http://acm.timus.ru

baidu.com

#include<bits/stdc++.h>
using namespace std;
struct node
{
    string a;
    int s;
}x;
bool cmp(node a,node b)
{
    if(a.s!=b.s)
        return a.s>b.s;
    else
        return a.a<b.a;
}
int main()
{
    int t,n,i;
    cin>>t;
    while(t--)
    {
        string a,s;
        cin>>n;
        map<string,int>ma;
        map<string,int>::iterator it;
        while(n--)
        {
            cin>>a>>s;
            vector<node>ve;
            if(a=="Visit")
                ma[s]++;
            if(a=="Display")
            {
                for(it=ma.begin();it!=ma.end();it++)
                {
                    if(it->first.find(s)==)
                    {
                        x.a=it->first;
                        x.s=it->second;
                        ve.push_back(x);
                    }
                }
                sort(ve.begin(),ve.end(),cmp);
                for(i=;i<ve.size();i++)
                    cout<<ve[i].a<<endl;
                cout<<endl;
            }
        }
    }
    return ;
}