Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <map>
- using namespace std;
- typedef struct team
- {
- vector<string> vPlayerList;
- int nWins;
- team() : nWins(0) {}
- } Team;
- int main()
- {
- cin.sync_with_stdio(false);
- cout.sync_with_stdio(false);
- int nTeams;
- cin >> nTeams;
- map<string, Team> teamList;
- for (int i = 0; i < nTeams; i++)
- {
- Team team;
- string szTeamName;
- int nTeamSize;
- cin >> szTeamName >> nTeamSize;
- team.vPlayerList.reserve(nTeamSize);
- while (nTeamSize--)
- {
- string szPlayer;
- cin >> szPlayer;
- team.vPlayerList.push_back(szPlayer);
- }
- teamList[szTeamName] = team;
- }
- int nGames;
- cin >> nGames;
- for (int i = 0; i < nGames; i++)
- {
- string szTeamName;
- cin >> szTeamName;
- teamList[szTeamName].nWins++;
- }
- map<string, int> mPlayerScores;
- for (const auto& item : teamList)
- {
- for (const string& str : item.second.vPlayerList)
- {
- mPlayerScores[str] += item.second.nWins;
- }
- }
- map<string, int>::iterator it = mPlayerScores.begin();
- while (it != mPlayerScores.end())
- {
- cout << it->second << " ";
- it++;
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement