#P7825. 「RdOI R3」VSQ
「RdOI R3」VSQ
Description
Let be a string with length at least . If the XOR of every length substring of is , then is called a "VS string".
You need to maintain a string of length , supporting the following operations:
$$\def\arraystretch{1.5} \begin{array}{|c|c|} \hline \textbf{Format} & \textbf{Description} \cr\hline \texttt{0 l r} & \text{Fill the interval }[l,r]\text{ with }0 \cr\hline \texttt{1 l r}& \text{Fill the interval }[l,r]\text{ with }1 \cr\hline \texttt{2 l r}& \text{Flip every bit in }[l,r]\text{, i.e., }1\text{ becomes }0\text{ and }0\text{ becomes }1 \cr\hline \texttt{3 l r k} & \text{Query how many substrings of length }k\text{ in }[l,r]\text{ are "VS strings"} \cr\hline \texttt{4 l r} & {\def\arraystretch{1}\begin{array}{c} \text{Query the length of the longest "VS string" within }[l,r]\text{,}\\\text{and output }1\text{ if no such substring exists in the interval} \end{array}} \cr\hline \end{array}$$Input Format
The first line contains two integers , representing the length of the string and the number of operations.
The second line contains integers, representing .
The next lines each contain three or four integers , representing one operation.
Output Format
For each query operation, output one integer per line, representing the corresponding answer.
5 7
0 1 1 0 1
0 1 2
2 1 5
3 1 5 3
2 1 3
2 2 3
3 1 5 3
4 1 5
2
3
5
10 9
0 1 1 0 1 1 0 1 1 0
3 1 5 3
4 2 9
4 1 4
3 4 10 4
3 4 10 3
4 1 5
4 9 10
4 4 6
4 5 9
1
3
2
0
1
3
2
2
3
10 10
0 0 0 1 0 0 0 1 0 0
2 7 10
4 6 9
3 2 9 7
1 6 7
4 10 10
1 1 3
3 4 7 3
4 2 8
1 6 9
4 5 6
4
0
1
1
3
2
Hint
Sample Explanation
Sample #1
| Number of operations | Input content | string | Answer |
|---|---|---|---|
0 1 2 |
|||
2 1 5 |
|||
3 1 5 3 |
|||
2 1 3 |
|||
2 2 3 |
|||
3 1 5 3 |
|||
4 1 5 |
Constraints
This problem uses bundled testdata.
For all testdata, , , , .
| subtask | Score | Time limit | Special property | |
|---|---|---|---|---|
| ms | None | |||
| ms | No operations | |||
| ms | No operation | |||
| are generated uniformly at random within their ranges | ||||
| ms | ||||
| None | ||||
| ms |
This problem may be slightly strict on constant factors.
The time limits are designed to keep the total time limit of all test points within s and to eliminate incorrect algorithms.
Translated by ChatGPT 5
京公网安备 11011102002149号