Problem 2. Manipulate Array
Здравейте! Постарах се да измисля доста кратък код за тази задача, защото видях, че всички останали решения, които намерих бяха с минимум 100 реда код. Когато пусна кода в judge ми дава 85/100 и един тест ми гърми. Някой може ли да ми помогне с отстраняването на тази грешка?
Problem 2. Manipulate Array
You will receive an array of strings and you have to execute some command upon it. You can receive three types of commands:
- Reverse – reverse the array
- Distinct – delete all non-unique elements from the array
- Replace {index} {string} – replace the element at the given index with the string, which will be given to you
Input
- On the first line, you will receive the string array
- On the second line, you will receive n – the number of lines, which will follow
- On the next n lines – you will receive commands
Output
At the end print the array in the following format:
{1st element}, {2nd element}, {3rd element} … {nth element}
Constraints
- For separator will be used only single whitespace
- n will be an integer in the interval [1…100]
Examples
Input |
Output |
one one one two three four five 3 Distinct Reverse Replace 2 Hello |
five, four, Hello, two, one |
Input |
Output |
Alpha Bravo Charlie Delta Echo Foxtrot 6 Distinct Reverse Replace 1 Charlie Distinct Reverse Replace 2 Charlie |
Alpha, Bravo, Charlie, Charlie, Foxtrot |