Advertisement
Guest User

a.cpp - NEERC Moscow Subregional 2015-16

a guest
Oct 17th, 2015
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. map<string, vector<string> > mp;
  5.  
  6. int main() {
  7.     int n; cin >> n;
  8.     string s;
  9.     string ss;
  10.     for(int q = 0 ; q < n ; q++) {
  11.         cin >> s;
  12.         ss = s;
  13.         for(int i = 0 ; i < ss.size() ; i++) {
  14.             if(s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  15.         }
  16.         string x = "", y = "";
  17.         bool sy = false;
  18.         for(int i = 0; i < s.size() ; i++) {
  19.             if(s[i] == '@') {
  20.                 sy = true;
  21.                 continue;
  22.             }
  23.             if(!sy) x += s[i];
  24.             else y += s[i];
  25.         }
  26.         if(y == "bmail.com") {
  27.             string new_x = "";
  28.             for(int i = 0 ; i < x.size() ; i++) {
  29.                 if(x[i] == '+') break;
  30.                 if(x[i] == '.') continue;
  31.                 new_x += x[i];
  32.             }
  33.             string z = new_x + "@" + y;
  34.             mp[z].push_back(ss);
  35.         } else {
  36.             mp[s].push_back(ss);
  37.         }
  38.     }
  39.     cout << mp.size() << "\n";
  40.     for(map<string, vector<string> >::iterator it = mp.begin() ; it != mp.end() ; ++it) {
  41.         cout << it->second.size() << " ";
  42.         for(vector<string>::iterator i = it->second.begin() ; i != it->second.end() ; ++i) {
  43.             cout << *i << " ";
  44.         }
  45.         cout << "\n";
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement