#include <iostream>
#include <map>
#include <string>
#include <set>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
map <string, set <string>> engLat, latEng;
while (n--) {
string eng, lat, word;
cin >> eng;
getline(cin, lat);
lat += ",";
for (int i = 3; i < lat.length(); i++) {
if (isalpha(lat[i])) word += lat[i];
else {
engLat[eng].insert(word);
word.clear();
i++;
}
}
}
for (auto x : engLat) {
for (auto y : x.first) {
latEng[y] = x.first;
}
}
cout << latEng.size() << endl;
for (auto x : latEng) {
cout << x.first << " - ";
int count = 1;
for (auto y : x.first) {
if (count < x.second.size()) {
cout << ", ";
count++;
}
cout << y;
}
cout << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWFwPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8c2V0PgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgICBpbnQgbjsKICAgIGNpbiA+PiBuOwogICAgbWFwIDxzdHJpbmcsIHNldCA8c3RyaW5nPj4gZW5nTGF0LCBsYXRFbmc7CiAgICB3aGlsZSAobi0tKSB7CiAgICAgICAgc3RyaW5nIGVuZywgbGF0LCB3b3JkOwogICAgICAgIGNpbiA+PiBlbmc7CiAgICAgICAgZ2V0bGluZShjaW4sIGxhdCk7CiAgICAgICAgbGF0ICs9ICIsIjsKICAgICAgICBmb3IgKGludCBpID0gMzsgaSA8IGxhdC5sZW5ndGgoKTsgaSsrKSB7CiAgICAgICAgICAgIGlmIChpc2FscGhhKGxhdFtpXSkpIHdvcmQgKz0gbGF0W2ldOwogICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICAgIGVuZ0xhdFtlbmddLmluc2VydCh3b3JkKTsKICAgICAgICAgICAgICAgIHdvcmQuY2xlYXIoKTsKICAgICAgICAgICAgICAgIGkrKzsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIAogICAgZm9yIChhdXRvIHggOiBlbmdMYXQpIHsKICAgICAgICBmb3IgKGF1dG8geSA6IHguZmlyc3QpIHsKICAgICAgICAgICAgbGF0RW5nW3ldID0geC5maXJzdDsKICAgICAgICB9CiAgICB9CiAgICAKICAgIGNvdXQgPDwgbGF0RW5nLnNpemUoKSA8PCBlbmRsOwogICAgCiAgICBmb3IgKGF1dG8geCA6IGxhdEVuZykgewogICAgICAgIGNvdXQgPDwgeC5maXJzdCA8PCAiIC0gIjsKICAgICAgICBpbnQgY291bnQgPSAxOwogICAgICAgIGZvciAoYXV0byB5IDogeC5maXJzdCkgewogICAgICAgIAlpZiAoY291bnQgPCB4LnNlY29uZC5zaXplKCkpIHsKICAgICAgICAJCWNvdXQgPDwgIiwgIjsKICAgICAgICAJCWNvdW50Kys7CiAgICAgICAgCX0KICAgICAgICAgICAgY291dCA8PCB5OwogICAgICAgIH0KICAgICAgICBjb3V0IDw8IGVuZGw7CiAgICB9CiAgcmV0dXJuIDA7Cn0=
MwphcHBsZSAtIG1hbHVtLCBwb211bSwgcG9wdWxhCmZydWl0IC0gYmFjYSwgYmFjY2EsIHBvcHVtCnB1bmlzaG1lbnQgLSBtYWx1bSwgbXVsdGE=
3
apple - malum, pomum, popula
fruit - baca, bacca, popum
punishment - malum, multa
prog.cpp: In function ‘int main()’:
prog.cpp:29:19: error: no match for ‘operator[]’ (operand types are ‘std::map<std::__cxx11::basic_string<char>, std::set<std::__cxx11::basic_string<char> > >’ and ‘char’)
latEng[y] = x.first;
^
In file included from /usr/include/c++/8/map:61,
from prog.cpp:2:
/usr/include/c++/8/bits/stl_map.h:490:7: note: candidate: ‘std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::__cxx11::basic_string<char>; _Tp = std::set<std::__cxx11::basic_string<char> >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, std::set<std::__cxx11::basic_string<char> > > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = std::set<std::__cxx11::basic_string<char> >; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::__cxx11::basic_string<char>]’
operator[](const key_type& __k)
^~~~~~~~
/usr/include/c++/8/bits/stl_map.h:490:7: note: no known conversion for argument 1 from ‘char’ to ‘const key_type&’ {aka ‘const std::__cxx11::basic_string<char>&’}
/usr/include/c++/8/bits/stl_map.h:510:7: note: candidate: ‘std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::__cxx11::basic_string<char>; _Tp = std::set<std::__cxx11::basic_string<char> >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, std::set<std::__cxx11::basic_string<char> > > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = std::set<std::__cxx11::basic_string<char> >; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::__cxx11::basic_string<char>]’
operator[](key_type&& __k)
^~~~~~~~
/usr/include/c++/8/bits/stl_map.h:510:7: note: no known conversion for argument 1 from ‘char’ to ‘std::map<std::__cxx11::basic_string<char>, std::set<std::__cxx11::basic_string<char> > >::key_type&&’ {aka ‘std::__cxx11::basic_string<char>&&’}