Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <string>
- #include <vector>
- #include <map>
- #include <algorithm>
- using namespace std;
- bool is_find(vector<string>& v, string el) {
- return find(v.begin(), v.end(), el) != v.end();
- }
- int main() {
- map<int, vector<string>> kidParticipants;
- string participant;
- cin >> participant;
- while (participant != "END") {
- int room;
- cin >> room;
- kidParticipants[room].push_back(participant);
- cin >> participant;
- }
- cin >> participant;
- while (participant != "END") {
- vector<int> rooms;
- for (auto& k : kidParticipants) {
- if (is_find(k.second, participant)) {
- rooms.push_back(k.first);
- }
- }
- cout << participant << ':';
- if (rooms.empty()) {
- cout << " Not found!\n";
- }
- else {
- for (int i = 0; i < rooms.size(); i++) {
- cout << ' ' << rooms[i];
- }
- cout << endl;
- }
- cin >> participant;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement