HDU 1263

 
很迷的map,虽然很基础不过很迷
1
#include<bits/stdc++.h> 2 using namespace std; 3 int main(){ 4 int N;cin>>N; 5 while(N--){ 6 int n;cin>>n; 7 map<string,map<string,int> >mapp; 8 while(n--){ 9 string p,f; 10 int num; 11 cin>>f>>p>>num; 12 mapp[p][f]+=num; 13 } 14 map<string,map<string,int> >::iterator i; 15 map<string,int>::iterator j; 16 for(i = mapp.begin(); i!=mapp.end();++i){ 17 cout<<i->first<<endl; 18 for(j = i->second.begin();j!=i->second.end();++j){ 19 cout<<" |----"<<j->first<<"("<<j->second<<")"<<endl; 20 } 21 } 22 if(N) cout<<endl; 23 } 24 return 0; 25 }

 

posted @ 2019-02-22 14:03  鹤花之歌  阅读(245)  评论(0编辑  收藏  举报