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

建议使用的浏览器:

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

3645:Code Management System

题目描述
Jack’s company has a very long program to modify. Each programmer edits some lines of that program and cannot add or delete any lines. A programmer can do three kinds of operations as below:

- SYNC: At the beginning, every programmer must do this to download the whole program from the code center to their local machine. This operation only executes once for each programmer.

- MODIFY: Modify a line of the code. The modification work will be temporarily done on the local computer.

- SUBMIT: Submit one’s whole local code to the code center. The code center will handle all possible changes and then send the whole newest program back to the submitter. We assume that the time duration of handling changes and sending back can be omitted.

The code center records the time and the performer of every operation.
As you see, a programmer can get the program from the code center only when he performs a SYNC or a SUBMIT operation. We call the version in the code center “standard version.” The code center keeps only ONE standard version.

Imagining there are two programmers who download the same version of the program and they both modify the ith line. Then they both submit their programs. Now what will the ith line be in the standard version? Jack figures out a rule. He gives each programmer a unique priority. When a programmer (Let’s name him Tom) modifies the ith line and then submit his program, the code center will handle the content of the ith line following the rules below:


1. If there was no accepted modification on the ith line before, Tom’s modification will be accepted. That means, the ith line in the standard version becomes the same as the ith line in the program submitted by Tom, and so Tom becomes the author of this line.
2. Otherwise, if the time of the last accepted modification on the ith line, is earlier than the time when Tom got the program from code center last time (Tom can get the program by SYNC or SUBMIT operation), Tom’s modification will be accepted. This situation means that there was no newly accepted modification on the ith line during the time from the ith line’s last accepted modification to Tom’s submission.
3. Otherwise, if Tom’s priority is higher than the priority of the last author of the ith line, Tom’s modification will be accepted.
4. In other cases, Tom’s modification on the ith line this time will be ignored and never be processed again.
5. If Tom’s modification was accepted, the code center would record the modification time of the ith line as the time when Tom’s SUBMIT operation happened.

Please note that a programmer can modify multiple lines before he submits, and his modification on some lines may be accepted, but on the other lines may be ignored.

For example, Alice and Bob are two programmers. Alice’s priority is 1 and Bob’s is 2(2 is higher than 1). In following case A and B, Bob’s modification on the first line will be accepted. However, Alice’s modification will be ignored in Case C but will be accepted in Case D.


Case A
[2010/07/18 12:00:00] Alice SYNC
[2010/07/18 12:00:01] Bob SYNC
Alice and Bob are editing the first line.
[2010/07/18 12:05:00] Alice SUBMIT
[2010/07/18 12:06:00] Bob SUBMIT


Case B
[2010/07/18 12:00:00] Alice SYNC
Alice is editing the first line.
[2010/07/18 12:05:00] Alice SUBMIT
[2010/07/18 12:05:01] Bob SYNC
Bob is editing the first line
[2010/07/18 12:06:00] Bob SUBMIT

Case C
[2010/07/18 12:00:00] Alice SYNC
[2010/07/18 12:00:02]Bob SYNC
Alice and Bob are editing the first line.
[2010/07/18 12:05:00]Bob SUBMIT
[2010/07/1812:06:00]Alice SUBMIT

Case D
[2010/07/18 12:00:00] Bob SYNC
Bob is editing the first line.
[2010/07/18 12:05:00]Bob SUBMIT
[2010/07/18 12:05:01]Alice SYNC
Alice is editing the first line
[2010/07/18 12:06:00]Alice SUBMIT


You need to help Jack to figure out who is the last author of every code line in the final standard version of the program.
输入解释
The input contains several test cases.
For each test case, the first line contains an integer n (0<n<=10000), representing the number of programmers. The following lines contain their working details.

For each programmer, the first line contains a string and two integers pi and qi. The string represents his/her name, which only contains letters. The length of each name is less than 30. pi is his/her priority number and qi is the number of operations his/her has done. Each of the following qi lines contains a single operation. The format is as following:

“[yyyy/mm/dd hh:mm:ss] OPERATION”

There is a blank between day(dd) and hour(hh), as well as the right square bracket and OPERATION. The OPERATION has three formats: “SYNC”, “MODIFY line_id” and “SUBMIT”. The line_id was an integer representing the certain line number on which this modification happens. There is a blank between MODIFY and line_id. There is no extra blank.

The line numbers and priority numbers are integers from 0 to 231-1. The sum of all the qi is less than or equal to 50000. You can assume that all operations happen in different time.

The input file ends by a single 0 in a line.

输出解释
For each test case, details of each modified line should show in a line. The format is as follows:

“line_id [yyyy/mm/dd hh:mm:ss] BY name”

The line_id is the certain line which has been modified. The date shows the time of its last accepted modification and name shows the author. There’s a single white blank between line_id and the left bracket, as well as the day(dd) and hour(hh), the right bracket and “BY”, “BY” and name. Beside these, there’s no spare white blank.

The lines are sorted increasingly by line_id. At the end of each test case, there is a single line contains a word “END”.

输入样例
2
Alice 1 3
[2010/07/18 12:00:00] SYNC
[2010/07/18 12:01:00] MODIFY 1
[2010/07/18 12:05:00] SUBMIT
Bob 2 3
[2010/07/18 12:00:01] SYNC
[2010/07/18 12:01:30] MODIFY 1
[2010/07/18 12:06:00] SUBMIT
2
Alice 1 3
[2010/07/18 12:05:01] SYNC
[2010/07/18 12:05:30] MODIFY 1
[2010/07/18 12:06:00] SUBMIT
Bob 2 3
[2010/07/18 12:00:01] SYNC
[2010/07/18 12:01:30] MODIFY 1
[2010/07/18 12:05:00] SUBMIT
0
输出样例
1 [2010/07/18 12:06:00] BY Bob
END
1 [2010/07/18 12:06:00] BY Alice
END

提示
The sample cases correspond to pervious Case A and Case D.
来自杭电HDUOJ的附加信息
Recommend lcy

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

源链接: HDU-3645

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

共提交 0

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