1018: Data manipulation
[Creator : ]
Description
Given a list of N integers ( 1 <= N <= 1000 ), there are 4 kinds of operations for the integers in the list:
1) add x y <-- insert integer y before location x (if x is not valid index, do nothing)
2) del x <-- delete the integer in location x (if x is not valid index, do nothing)
3) ins x y <-- insert y before all elements whose value is x
4) delall x <-- delete all elements whose value is x
(The location is index of the list, starting from 0 )
1) add x y <-- insert integer y before location x (if x is not valid index, do nothing)
2) del x <-- delete the integer in location x (if x is not valid index, do nothing)
3) ins x y <-- insert y before all elements whose value is x
4) delall x <-- delete all elements whose value is x
(The location is index of the list, starting from 0 )
Input
One integer in the first line which is N
the second line has N integers
the third line contains one integer M ( 1<=M <= 5000 )
In the following M lines, each contains one kind of operators described in the description
the second line has N integers
the third line contains one integer M ( 1<=M <= 5000 )
In the following M lines, each contains one kind of operators described in the desc
Output
please output the final data list in one line
Sample Input Copy
5
1 2 3 4 5
7
add 0 10
add 12 90
add 0 5
add 3 7
del 2
ins 5 7
delall 7
Sample Output Copy
5 10 2 3 4 5
HINT
Given 1 2 3 4 5:
add 0 10 ---> the list is : 10 1 2 3 4 5
add 12 90 ---> do nothing because 12 is invalid index (out of boundary)
add 0 5 --> the list is : 5 10 1 2 3 4 5
add 3 7 ---> the list is 5 10 1 7 2 3 4 5
del 2 --> the list is 5 10 7 2 3 4 5
ins 5 7 --> the list is 7 5 10 7 2 3 4 7 5
delall 7 --> the list is 5 10 2 3 4 5
add 0 10 ---> the list is : 10 1 2 3 4 5
add 12 90 ---> do nothing because 12 is invalid index (out of boundary)
add 0 5 --> the list is : 5 10 1 2 3 4 5
add 3 7 ---> the list is 5 10 1 7 2 3 4 5
del 2 --> the list is 5 10 7 2 3 4 5
ins 5 7 --> the list is 7 5 10 7 2 3 4 7 5
delall 7 --> the list is 5 10 2 3 4 5