#P13688. 【MX-X16-T6】「DLESS-3」XOR and Powerless Suffix Mode
【MX-X16-T6】「DLESS-3」XOR and Powerless Suffix Mode
Description
We define a value as a "Powerless Suffix Mode" of a subsequence of a given sequence , with a parameter , if and only if the following conditions are met:
- is a mode of the subsequence (i.e., one of the most frequent elements).
- Let the subsequence be formed by elements of at indices , and let . There do not exist indices (of the sequence ) such that , , , and .
- The number of occurrences of in the subsequence does not exceed of the total number of occurrences of in the entire sequence .
You are given a sequence of non-negative integers and queries. Each query provides three integers . For each query, consider the subarray as the base sequence. You need to calculate the XOR sum of all Powerless Suffix Modes over all subsequences of . If a particular subsequence has multiple Powerless Suffix Modes, all of them should be included in the XOR sum.
Input Format
The first line contains two integers, and .
The second line contains integers, representing the sequence .
Each of the next lines contains three integers, , describing one query.
Output Format
For each query, output a single integer on one line, representing the answer.
13 6
1 1 4 5 1 4 1 9 1 9 8 1 0
7 9 100
3 6 50
7 11 100
7 11 99
1 3 100
2 4 100
9
0
8
0
4
0
18 1
1 1 1 1 1 1 2 2 2 2 2 2 4 4 4 4 4 4
1 18 40
7
Hint
For all test cases, it is guaranteed that:
This problem uses subtasks for scoring. The descriptions of the subtasks are as follows:
| Subtask | Score | |||
|---|---|---|---|---|
京公网安备 11011102002149号