编程介的小学生 2020-01-03 19:50 采纳率: 20.5%
浏览 88

Batch System 批处理问题

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向