Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Purpose: To learn and practice dictionaries Problem Statement: One day, going through old books in the attic, a student Bob found an English - Latin

Purpose: To learn and practice dictionaries
Problem Statement:
One day, going through old books in the attic, a student Bob found an English-Latin dictionary. By that time he spoke English fluently, and his dream was to learn Latin. So finding the dictionary was just in time.
Unfortunately, full-fledged language studying process requires also another type of dictionary: Latin-English. For lack of a better way he decided to make a second dictionary using the first one.
As you know, the dictionary consists of words, each of which contains multiple translations. For each Latin word that appears anywhere in the dictionary,
Bob has to find all its translations (that is, all English words, for which our Latin word is among its translations), and take them and only them as the translations of this Latin word.
Help him to create a Latin-English.
The first line contains a single integer N- the number of English words in the dictionary - followed by N dictionary entries. Each entry is contained on a separate line, which contains first the English word, then a hyphen surrounded by spaces and then comma-separated list with the translations of this English word in Latin. All the words consist only of lowercase English letters. The translations are sorted in lexicographical order. The order of English words in the dictionary is also lexicographic.
Print the corresponding Latin-English dictionary in the same format. In particular, the first word line should be the lexicographically minimal translation of the Latin word, then second in that order, etc. The English words inside each line should also be sorted lexicographically.
Criteria:
\table[[# Input,Output],[3,baca - fruit],[apple - malum, pomum, popula,malum - apple, punishment]]
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions