HDU 1263. map套map
原题链接
简单
作者:
史一帆
,
2021-04-19 19:02:53
,
所有人可见
,
阅读 161
#include <iostream>
#include <string>
#include <map>
using namespace std;
int n, m;
map<string, int> mp1;
map<string, map<string, int>> mp2;
int main()
{
cin >> n;
while (n -- )
{
mp1.clear();
mp2.clear();
cin >> m;
while (m -- )
{
string name, place;
int sum;
cin >> name >> place >> sum;
mp2[place][name] += sum;
}
for (map<string, map<string, int>>::iterator it2 = mp2.begin(); it2 != mp2.end(); it2 ++ )
{
mp1 = it2 -> second;
cout << it2 -> first << endl;
for (map<string, int>::iterator it1 = mp1.begin(); it1 != mp1.end(); it1 ++ )
{
cout << " |----" << it1 -> first << '(' << it1 -> second << ')' << endl;
}
}
if (n != 0) cout << endl;
}
return 0;
}
兄弟有时间填个邀请码hhhhhhhhh(可以得AC币,邀请码在学生认证那填) 我的邀请码是:GUDFH