当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

4286:Data Handler

题目描述
  You are in charge of data in a company, so you are called "Data Handler". Different from the data in computer, the data you have are really in huge volume, and each data contains only one integer. All the data are placed in a line from left to right. There are two "hand" to handle the data, call hand "L" and hand "R". Every hand is between two adjacent data or at the end of the data line.
  In one day, the company gives you many commands to handle these data, so you should finish them one by one. At the beginning, there are N data, and hand "L" and "R" are in some positions. Each command is one the following formats:
  (1)MoveLeft L/R: it means that you should move the hand "L"/"R" left one data unit;


  (2)MoveRight L/R: it means that you should move the hand "L"/"R" right one data unit;



  (3)Insert L X: it means that you should insert the data that contains X at the right of the hand "L";



  (4)Insert R X: it means that you should insert the data that contains X at the left of the hand "R";



  (5)Delete L: it means that you should delete the one data at the right of the hand "L";



  (6)Delete R: it means that you should delete the one data at the left of the hand "R";



  (7)Reverse: it means that you should reverse all the data between hand "L" and hand "R".


  After finish all the commands, you should record all the data from left to right. So please do it.
输入解释
  The first line contains an integer T(1<=T<=10), the number of test cases.
  Then T test cases follow. For each test case, the first line contains an integer N(1<=N<=500000), the number of data at the beginning. The second line contains N integers, means the integer in each data, from left to right. The third line contains two integers L and R (1<=L<=R<=N), the positions of hand "L" and hand "R". It means that hand "L" is at the left of the L-th data and hand "R" is at the right of the R-th data. The fourth line contains one integer M(1<=M<=500000), the number of commands. Then M lines follow, each line contains a command in the above format. All the integers in the data will in range [-10000,10000].
  It is guaranteed that there are always some data between hand "L" and "R", and if the hand is at the left/right end of the data line, it will not receive the command MoveLeft/MoveRight.
  Because of large input, please use scanf instead of cin.
输出解释
  For each test case, output the integers in the data from left to right in one line, separated in a single space.
  Because of large output, please use printf instead of cout.
  
输入样例
2
5
1 2 3 4 5
1 5
5
MoveLeft R
Insert R 6
Reverse
Delete R
Insert L 7
5
6536 5207 2609 6604 -4046
1 3
5
Delete L
Insert R -9221
Reverse
Delete L
MoveRight L
输出样例
7 6 4 3 2 5
2609 5207 6604 -4046
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-4286

最后修改于 2020-10-25T23:12:03+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
20000/10000MS(Java/Others) 32768/32768K(Java/Others)