CEN254 Midterm |
Старт: 09.мая.2017 в 14:05:00
Финиш: 09.мая.2017 в 15:02:00
Турнир завершён!
• Турнирная таблица
|
|
Лимит времени 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
- The number
- The position to be inserted/placed
- If the char is R
- The number of elements to be removed
- 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
|
Для отправки решений необходимо выполнить вход.
|