二维map
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
for(int cas=0;cas<t;cas++)
{
map<string,map<string,int> >p;
map<string,map<string,int> >::iterator it;
map<string,int>::iterator kk;
int n;
scanf("%d",&n);
string name,place;
int num;
for(int i=0;i<n;i++)
{
cin>>name>>place>>num;
///string不能用%s
p[place][name]+=num;
}
for(it=p.begin();it!=p.end();it++)
{
cout<<it->first<<endl;
for(kk=it->second.begin();kk!=it->second.end();kk++)
{
cout<<" |----"<< kk->first <<"("<< kk->second <<")"<<endl;
}
}
if(cas!=t-1)
printf("\n");
}
return 0;
}
要肥家啦O(∩_∩)O~~