luogu#P5048. [Ynoi2019 模拟赛] Yuno loves sqrt technology III

[Ynoi2019 模拟赛] Yuno loves sqrt technology III

Background

Problem Description

You are given a sequence aa of length nn and mm queries. For each query, you need to output the number of occurrences of the mode in a given interval, and the queries are forced to be online.

Input Format

The first line contains two integers n,mn, m.

The second line contains nn integers representing the sequence.

Then follow mm lines, each containing two numbers representing the query interval.

This problem is forced to be online: in each query, the input numbers should be xor\operatorname{xor} with lastanslastans. For the first query, lastans=0lastans = 0 by default.

Output Format

Output mm lines, each line contains one integer representing the answer to the query.

4 1
2 3 3 3
2 4
3

Hint

1n,m,ai5×1051\leq n, m, a_i \leq 5\times 10^5

There exists an O(n1.48541)O( n^{1.48541} ) algorithm.

Source By nzhtl1477.

Translated by ChatGPT 5