天天看點

[ACM_動态規劃] UVA 12511 Virus [最長公共遞增子序列 LCIS 動态規劃]

We have a log file, which is a sequence of recorded events. Naturally, the timestamps are strictly increasing.

However, it is infected by a virus, so random records are inserted (but the order of original events is preserved). The backup log file is also infected, but since the virus is making changes randomly, the two logs are now different.

Given the two infected logs, your task is to find the longest possible original log file. Note that there might be duplicated timestamps in an infected log, but the original log file will not have duplicated timestamps.

The first line contains T (   T

[ACM_動态規劃] UVA 12511 Virus [最長公共遞增子序列 LCIS 動态規劃]

100), the number of test cases. Each of the following lines contains two lines, describing the two logs in the same format. Each log starts with an integer n (   1

[ACM_動态規劃] UVA 12511 Virus [最長公共遞增子序列 LCIS 動态規劃]

n

[ACM_動态規劃] UVA 12511 Virus [最長公共遞增子序列 LCIS 動态規劃]

1000), the number of events in the log, which is followed by n positive integers not greater than 100,000, the timestamps of the events, in the same order as they appear in the log.   

For each test case, print the number of events in the longest possible original log file.   

[ACM_動态規劃] UVA 12511 Virus [最長公共遞增子序列 LCIS 動态規劃]
[ACM_動态規劃] UVA 12511 Virus [最長公共遞增子序列 LCIS 動态規劃]

<a></a>

繼續閱讀