#P10856. 【MX-X2-T5】「Cfz Round 4」Xor-Forces
【MX-X2-T5】「Cfz Round 4」Xor-Forces
Background
Original link: https://oier.team/problems/X2E.
✿(。◕ᴗ◕。)✿
Problem Description
Given an array of length with indices starting from , maintain operations:
- Operation 1: Given , define an array such that , and modify to . Here denotes the bitwise XOR operation.
- Operation 2: Given , query how many color segments are in the subarray of whose indices are between and . It is not guaranteed that . If , please swap yourself.
Here, a color segment is defined as a maximal subarray in which all numbers are equal.
Some test points require strict online processing.
Input Format
The first line contains three integers , where is a parameter that decides whether strict online processing is required.
The second line contains integers .
Then follow lines. Each line contains two or three integers describing one operation. The first integer indicates the operation type.
- If , it is Operation 1. The next integer is , satisfying .
- If , it is Operation 2. The next two integers are , satisfying , . It is not guaranteed that . If , please swap yourself.
- Here denotes the answer to the previous query. In particular, if there has been no query before, then .
Output Format
Output several lines. Each line contains one integer, in order, representing the answer to each query.
0 3 3
1 2 1 3 2 4 5 1
2 1 5
1 3
2 5 1
5
4
1 3 3
1 2 1 3 2 4 5 1
2 1 5
1 6
2 0 4
5
4
1 4 16
12 9 5 9 12 12 9 12 9 16 5 9 12 16 9 5
2 0 4
1 15
2 14 0
1 15
2 6 0
2 4 14
1 0
1 14
2 4 10
2 6 3
1 7
2 4 13
1 3
1 3
2 4 3
2 15 2
5
7
4
7
9
5
7
2
11
Hint
[Sample Explanation #1]
This sample allows offline processing.
Initially, .
The subarray of with indices between and is , and its number of color segments is .
After the rearrangement operation, .
The subarray of with indices between and is , and its number of color segments is .
[Sample Explanation #2]
Except for strict online processing, this sample is exactly the same as Sample #1.
[Constraints]
For all testdata, , , , , , , .
This problem uses bundled testcases.
- Subtask 1 (15 points): , , .
- Subtask 2 (15 points): , there is no Operation 1.
- Subtask 3 (20 points): , for all Operation 2 queries, either , or .
- Subtask 4 (20 points): .
- Subtask 5 (30 points): .
Note: Subtask 5 depends on the first four subtasks. Only after passing the first four subtasks can you try to obtain the score for this subtask.
Translated by ChatGPT 5