F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Batch System

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)
Total Submission(s): 146    Accepted Submission(s): 12


Problem Description
Large distributed data center so-called ¡°bigtable¡± receives a huge number of update queries every minute from servers all over the world. The engineers want to make the system works more efficiency, so they come up with a batch system for bigtable.
We can denote the data in the bigtable as an infinity text data. Every client can send commands to the bigtable server to editing the text. Once the client connects to the bigtable server, the cursor for the client is positioned before the first character of the text before performing any commands. The bigtable only supports three operations below:

When a new client connects the server, it sends all the operations to the bigtable. And then the next client can connect and perform its own operation list.
  The batch system is designed to save the traffic volume. It merges all the clients operation together to one equivalent operation list. But their engineers soon noticed that it is hard to make the resulted operation list shortest.
  They ask you, their senior programmer, to make up a solution, give the operation lists with minimum length and let the delete operations before the insert operations if possible.
 

Input
The first line contains the number of test cases. The description of T tests follow.
  The first line of each test case contains the amount of clients n (1 <= n <= 10000). You can assume the client comes exactly in the order of the input.
The description of operation list of each client follows. The first line of each operation list contains the number of operations m first (1 <= m <= 10). The next m lines contain the description of each operation in the format given above. 1 <= k <= 100000 for R and D operations, and 1 <= k <= 10 for C operations. The strings in C operations consist of latin letters and digits only.
 

Output
For each test case your program should print the result of batch system. The format of the command should be the same as the input file, except the limitations of m and k. The result should contain the least possible number of operations. The delete operations should precede the insert operations if possible. If the result contains no operations, just print 0 instead.
 

Sample Input
1 2 4 R 4 C 3 abc R 2 C 3 xyz 3 R 7 C 3 def D 3
 

Sample Output
3 R 4 D 2 C 8 abcdefyz
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-23 02:43:36, Gzip enabled