一维map是一个键对应一个值
二维map是两个键组成一个一个键对应一个值
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
using namespace std;
int main(){
int t;
scanf("%d",&t);
while(t--){
int n;
scanf("%d",&n);
std::map<string, map<string,int> > ma;
std::map<string, map<string,int> >::iterator it;
while(n--){
string kind,where;
int number;
cin>>kind>>where>>number;
ma[where][kind]+=number;
}
for(it=ma.begin();it!=ma.end();it++){
cout<<it->first<<endl;
std::map<string, int>::iterator it2;
for(it2=it->second.begin();it2!=it->second.end();it2++){
cout<<" |----"<<it2->first<<"("<<it2->second<<")"<<endl;
}
}
if(t!=0)putchar('\n');
}
return 0;
}