HDU1263 map二维运用
#include <iostream> #include <cstdio> #include <cstring> #include <map> #include <algorithm> using namespace std; int main() { int T, m; cin >> T; while(T--) { map<string,map<string,int> >mp; string place, name; int num; cin >> m; for(int i=0; i<m; i++) { cin >> name >> place >> num; mp[place][name]+=num;; } for(map<string,map<string,int> >::iterator iter1=mp.begin(); iter1!=mp.end(); iter1++) { cout << iter1->first <<endl; for(map<string,int >::iterator iter2=iter1->second.begin(); iter2!=iter1->second.end(); iter2++) cout << " |----" << iter2->first << "(" << iter2->second << ")" <<endl; } if(T) cout << endl; } return 0; }