#P6514. [QkOI#R1] Quark and Strings
[QkOI#R1] Quark and Strings
Description
You need to maintain a sequence of strings , where there are strings, all initially empty. Then there are operations, and two types of operations are supported. Let the current operation be the -th one. The character set in this problem is :
1 l rmeans appending the character to the end of every string whose index is in . Here is an integer in the range .2 l rmeans querying the length of the longest common subsequence of all strings whose indices are in . When , we consider the longest common subsequence length to be the length of that string.
Input Format
The first line contains two positive integers .
The next lines each contain three positive integers in the form 1 l r or 2 l r.
Output Format
For each operation , output one line with a non-negative integer as your answer.
5 3
1 1 3
1 1 5
2 1 4
1
8 8
2 8 8
1 3 8
2 5 8
1 1 8
1 1 1
2 3 5
2 1 7
1 2 7
0
1
2
1
Hint
Sample Explanation
For the first sample:
After the first operation, the sequence is .
After the second operation, the sequence is .
For the third operation, it is easy to see that the longest common subsequence queried is , with length .
Constraints
This problem uses bundled testdata.
- Subtask 1 (10 pts): .
- Subtask 2 (20 pts): .
- Subtask 3 (15 pts): , operation occurs no more than times, time limit ms.
- Subtask 4 (15 pts): , operation occurs no more than times, time limit ms.
- Subtask 5 (40 pts): no special restrictions, time limit ms.
For of the data, . Except for the specially marked Subtasks, the time limit for the other Subtasks is ms.
Translated by ChatGPT 5
京公网安备 11011102002149号