Advertisement
xT30x

Untitled

Oct 24th, 2022
647
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. using ll = long long;
  5. using ld = long double;
  6.  
  7. int main()
  8. {
  9.     ll n;
  10.     while (cin >> n && n != 0)
  11.     {
  12.         cin.ignore();
  13.         map<string, set<string>> z1;
  14.         while (n-- > 0)
  15.         {
  16.             string x;
  17.             getline(cin, x);
  18.             stringstream ss(x);
  19.             ss >> x;
  20.             string ax;
  21.             while (ss >> ax)
  22.             {
  23.                 z1[ax].insert(x);
  24.             }
  25.         }
  26.         for (auto cl : z1)
  27.         {
  28.             cout << cl.first << " ";
  29.             for (auto cs : cl.second)
  30.             {
  31.                 cout << cs << " ";
  32.             }
  33.             cout << endl;
  34.         }
  35.         cout << endl;
  36.     }
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement