1398 - I2P (II) 2018_Yang_hw1 Scoreboard

Time

2018/03/01 17:00:00 2018/03/09 13:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11832 Play cards

11832 - Play cards   

Description

Niflheimr is playing cards with his friends. As a CS student, he wants to play in a programmer way. He decides to write a program for shuffling the cards. By the way, more friends may come while he is shuffling cards, so sometimes he needs to insert new cards into the card stack, too.

 

Hint: You can use linked list to implement.

Input

First line of input contains two integer nm, representing # of cards in the beginning and # of operations.
 
Next line contains n integers, representing the number on each card from the top (index 0) to the buttom (index n-1).
 
Each of the next m lines contains an operation. Operations begin with ADD or CUT.
  • ADD idx num: Add a new card with number num before card idx.
  • CUT a b: Move cards whose index between a and a+b-1 ( [a, a+b) ) to the top of the card stack. Order of the cards inside the moved part won't be changed.
Index of a card means # of cards on the top of that cardIt may change after operations.
 
It is guaranteed that:
  • 1 ≤ n, m ≤ 104
  • Number on cards are non-negative integer and do not exceed 107
  • # of cards in the card stack will never exceeds 2*104
  • in CUT operation, card with index = a+b-1 always exists.

Output

Print out the card stack from top (index 0) to buttom (largest index), each number occupies one line.

Sample Input  Download

Sample Output  Download

Tags




Discuss