#K74032. Group Customer Orders by Name
Group Customer Orders by Name
Group Customer Orders by Name
You are given a list of customer orders. Each order consists of a customer's name and a cuisine type. Your task is to group the orders by customer name and then, for each customer, sort the list of cuisines in alphabetical order.
The input is provided from standard input. The first line will contain a single integer n representing the number of orders. The following n lines each contain two strings: the customer name and the cuisine type. The output should be a JSON-style dictionary (i.e. an object) where each key is a customer's name and its corresponding value is a list of cuisines sorted in alphabetical order.
Note: Sorting is done only on the list of cuisines for each customer. The order of customer keys in the output does not matter.
The problem may be expressed mathematically as: if we denote by \(O = [(c_1, t_1), (c_2, t_2), \dots, (c_n, t_n)]\) where each \(c_i\) is a customer and \(t_i\) is a cuisine, then for each distinct customer \(c\) we output the pair \( (c, sorted(\{t : (c, t) \in O\}))\).
inputFormat
The first line of input contains an integer \(n\) — the number of orders. Each of the next \(n\) lines contains two space-separated strings: a customer's name and a cuisine type.
outputFormat
Output a JSON-style dictionary where each key is a customer's name and the associated value is a list containing that customer's cuisines sorted in alphabetical order. The output should be printed as a single line to standard output.
## sample5
Alice Italian
Bob Mexican
Alice Japanese
Bob Chinese
Alice Mexican
{"Alice": ["Italian", "Japanese", "Mexican"], "Bob": ["Chinese", "Mexican"]}