Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <map>
- #include <set>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- map<string, map<string, set<string>>> info;
- string continent, country, city;
- for (size_t i = 0; i < n; i++) {
- cin >> continent >> country >> city;
- info[continent][country].insert(city);
- }
- for (auto i = info.begin(); i != info.end(); i++) {
- cout << '\n' << i->first << ':';
- for (auto j = i->second.begin(); j != i->second.end(); j++) {
- cout << '\n' << j->first << " -> ";
- int len = j->second.size();
- for (auto k = j->second.begin(); k != j->second.end(); k++) {
- cout << k->c_str();
- if (--len != 0) {
- cout << ", ";
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement