Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <string>
- #include <vector>
- #include <set>
- #include <map>
- using namespace std;
- vector<string> string_split(string& str, string sep) {
- vector<string> v;
- while (!str.empty()) {
- size_t index = str.find(sep);
- v.push_back(str.substr(0, index));
- str.erase(0, index + sep.size());
- }
- return v;
- }
- bool is_find(vector<string>& v, string el) {
- return find(v.begin(), v.end(), el) != v.end();
- }
- int main() {
- string line;
- getline(cin, line);
- vector<string> participants = string_split(line, ", ");
- getline(cin, line);
- vector<string> songs = string_split(line, ", ");
- map<string, set<string>> info;
- set<int> valueSize;
- getline(cin, line);
- while (line != "dawn") {
- vector<string> tokens = string_split(line, ", ");
- string participant = tokens[0], song = tokens[1], award = tokens[2];
- if (is_find(participants, participant) && is_find(songs, song)) {
- info[participant].insert(award);
- valueSize.insert(info[participant].size());
- }
- getline(cin, line);
- }
- auto it = valueSize.end();
- if (info.size() > 0) {
- while (info.size() != 0) {
- int maxSize = *--it;
- for (auto& i : info) {
- if (i.second.size() == maxSize) {
- cout << i.first << ": " << i.second.size() << " awards" << endl;
- for (auto& v : i.second) {
- cout << "--" << v << endl;
- }
- info.erase(i.first);
- break;
- }
- }
- }
- }
- else {
- cout << "No awards\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement