HDU - 1263 水果
用一个map<string,map<string,int>>容器嵌套,存水果和产地之间的数量,最后遍历输出即可
#include<iostream>
#include<map>
using namespace std;
int main()
{
int t;cin>>t;
while(t--)
{
map<string,map<string,int>>x;
int n;cin>>n;
for(int i=0;i<n;i++)
{
string a,b;int c;
cin>>a>>b>>c;
x[b][a]+=c;
}
for(auto &it:x)
{
cout<<it.first<<endl;
for(auto &jt:it.second)
cout<<" |----"<<jt.first<<"("<<jt.second<<")"<<endl;
}
if(t) cout<<endl;
}
return 0;
}