编程介的小学生 2020-02-16 01:50 采纳率: 20.5%
浏览 179

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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
    • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
    • ¥50 需求一个up主付费课程
    • ¥20 模型在y分布之外的数据上预测能力不好如何解决