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

Разделы > Linear Data Structures: Arrays > задача:


51118 - Place 7 to the 5th position

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

Задачи раздела

• 51123 - Mr. Li Criteria
• 51124 - Easy Tiae words
• 51145 - Graduation Exam
• 51117 - The Most Crowded
• 51146 - Popular Baby Names
• 51131 - Running After a Thief
• 51143 - Departments Competition
• 50994 - The Most Crowded Station
• 51118 - Place 7 to the 5th position
• 51132 - Problem Solving Competition
• 51121 - Complexity power of a nu...
• 51119 - Evaluating Prefix expressions
• 50563 - Modul i gjate
• 50594 - Transformimet
• 51182 - Count and Sum 2
• 51193 - The max element of k-th co...
• 51194 - The difference between max...

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

Если у вас есть предложения или пожелания по работе 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