ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Турниры > CEN254 Midterm > задача:


2. 51118 - Place 7 to the 5th position

CEN254 Midterm

Старт: 09.мая.2017 в 14:05:00
Финиш: 09.мая.2017 в 15:02:00
Турнир завершён!
• Турнирная таблица

Гость
• Вопросы к жюри (1)

Задачи турнира

• 1. 51117 - The Most Crowded
• 2. 51118 - Place 7 to the 5th po...
• 3. 51119 - Evaluating Prefix express...
• 4. 50836 - Censored

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Place 7 to the 5th position

You will be given a list of numbers. Then, you will be given operations like inserting or removing elements to the list into/from specific positions. The sequence of instructions starts with a letter and followed by 2 integers. The first letter may be "P" or "R". "P" means Place and "R" means remove. For example if you have the list: 1 2 3 4 5 6 7 and then if you are given the sequence of "P 3 5". It means place 3 to the fifth position in the list. Then the new list will be: 1 2 3 4 3 5 6 7. Then, if you are given the instruction "R 2 3" "Remove 2 elements starting from the third position". Then you will have: 1 2 3 5 6 7.

Question: Write a program that reads the given information and shows the list after the process.

Input specification: You will be given two integers: the number of integers in the initial list (n), and the number of operations (m). The following line contains n integers (numbers are between -9999 and +9999). Then, the following m lines contain a char and two integers.

  • If the char is P
    1. The number
    2. The position to be inserted/placed
  • If the char is R
    1. The number of elements to be removed
    2. Starting position to remove
where 1 ≤ n ≤ 10,000 and 1 ≤ m ≤ 2,000.

Output specification: Show the list at the end of instructions.

Sample Input 1 Sample Input 2
7 2
1 2 3 4 5 6 7
P 3 5
R 2 3
8 4
-1 0 -13 -15 15 -18 13 19
P -13 7
R 2 6
P 0 6
R 2 4
Sample Output 1 Sample Output 2
1 2 3 5 6 7 -1 0 -13 0 13 19



Для отправки решений необходимо выполнить вход.

www.contester.ru