Hide

Problem A
Liquid Assets

/problems/liquidassets/file/statement/en/img-0001.jpg

You are but a humble villager with big dreams, and they are finally coming true! You have just been promoted to “general manager” at the best (only) tavern in your town, Creeper County.

You have much loyalty to this town - your original spawn point - but it’s not exactly a popular tourist destination. (It probably has something to do with the unfortunate name.) As a result, the tavern is on the verge of bankruptcy. But, after hours of boring work that only an NPC would do, you’ve come across something startling: the business is spending way too much money on receipt ink! Instead of spelling out “rabbit stew” on a receipt, for example, you could simply write “rbt stw” and get the same information across. All you have to do to save your beloved tavern from bankruptcy is write a program that will remove all of the unnecessary letters from the meal titles on your receipts! Are you up to the task?

You want to remove letters from each word according to the following 2 rules:

  1. First, if the word contains any adjacent repeated letters, all but one should be removed (eg. in “coffee”, one of the f’s and one of the e’s should be removed).

  2. Then, any remaining vowels - a, e, i, o, or u - should be removed, unless they are the first or last letter in a word (eg. in “orange” the “a” should be removed, but the “o” and “e” should not).

Input

The input consists of two lines. The first line contains an integer $n$ ($0 < n < 1\, 000$), denoting the number of words in the meal title. The second line is a string $S$, the meal title, consisting of $n$ space-separated words. Each word $w$ ($0 < |w| < 100$) will consist of the $26$ lowercase letters in the standard English alphabet: [a-z].

Output

Output a single string: the meal title $S$ with all unnecessary letters removed from each word.

Sample Input 1 Sample Output 1
5
baked potato and beetroot soup
bkd ptto and btrt sp
Sample Input 2 Sample Output 2
9
dark chocolate coffee cake with a mocha mascarpone frosting
drk chclte cfe cke wth a mcha mscrpne frstng
CPU Time limit 1 second
Memory limit 1024 MB
Author
Reiya Downs
Source CodeSprint LA 2021
License Creative Commons License (cc by-sa)

Please log in to submit a solution to this problem

Log in